public static string converToLetter(int n)
{
char[] letter = new char[10];
int nextValue = n;
int varBase = 26;
int i = 0;
while (nextValue > 0)
{
nextValue--;
int reminder = nextValue % varBase;
nextValue = nextValue / varBase;
char id = (char)(65 + reminder);
letter[i] = id;
i++;
}
letter.Reverse();
return new string(letter.ToArray());
}
No comments:
Post a Comment