the following code converts characters A-Z to a number between 1 and 26, all are upper case for simplicity.
static void Main(string[] args)
{
string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
foreach (char c in letters)
{
Console.WriteLine(c +" = " + CharToNumber(c));
Console.ReadLine();
}
}
static int CharToNumber(char character)
{
// index starts at 0, 65 is the ascii code for A hence the program -64 so start at 1 therefore A=1
return (int)Char.ToUpper(character) - 64;
}
static char NumberToChar(int number)
{
// code here
}
}
}
I am trying to do the same but vice versa, so convert that number back to the same character. I am unsure on where to start. Any idea much appreciated, thank you