Incrementing alphabets
I am trying to create a function which will give me alphabet position when an index is passed. It will be same like how excel shows it's columns. A...Z, AA,AB.... I wrote the below function to get the results upto Z. It looks like static string GetColumnName(int index) { const int alphabetsCount = 26; if (index <= alphabetsCount) { int code = (index - 1) + (int)'A'; return char.ConvertFromUtf32(code); } return string.Empty; } This works fine until 'Z'. It return 'A' if I pass 1 and return 'B' if I pass 2 and so on. But, I am not able to figure out how will I get AA when I pass 27 to this