fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. private const int NumbersOfLettersInAlphabet = 26;
  6.  
  7. public static void Main()
  8. {
  9. Console.WriteLine(ExcelNumerationToDecimal("AB"));
  10.  
  11. }
  12.  
  13. public static int ExcelNumerationToDecimal(string columnName)
  14. {
  15. var columnNumber = 0;
  16. for (var i = 0; i < columnName.Length; i++)
  17. {
  18. columnNumber += (columnName[columnName.Length - i - 1] - '@') * (int)Math.Pow(NumbersOfLettersInAlphabet, i);
  19. }
  20. return columnNumber;
  21. }
  22. }
Success #stdin #stdout 0.03s 23872KB
stdin
Standard input is empty
stdout
28