I'm trying to write a function that takes a revision number (int) and turns it into a revision name (string). The formula should produce outputs similar to this:
Number Name 1 A 2 B 3 C ... ... 25 Y 26 Z 27 AA 28 AB 29 AC ... ... 51 AY 52 AZ 53 BA 54 BB 55 BC ... ...
This seems simple, but I think it might involve recursion and I'm terrible at that. Any suggestions?
I think this is the same as working out the Excel column name from a column number:
private string GetExcelColumnName(int columnNumber)
{
int dividend = columnNumber;
string columnName = String.Empty;
int modulo;
while (dividend > 0)
{
modulo = (dividend - 1) % 26;
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
dividend = (int)((dividend - modulo) / 26);
}
return columnName;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With