I have a homework assignment where the program will accept any phone number in the format similar to 555-GET-FOOD. The task is to map the alphabetic letters to numbers and tran
It looks like you did attempt to use TryParse:
//ch = Enum.TryParse(AlphaNumber);
That is the method that you probably want to use. But there are a number of problems with it in that form, which probably gave you errors as you mentioned.
The parameters this method expects are a string (which matches the enumerated constant, or name from the enum) and an out parameter of the type of the enum you want to parse. The method return a bool.
If the TryParse is successful then the method returns TRUE with the corresponding value from the enum set in the out parameter.
This code should allow you to get the result you want as an int using your variable ch as a string for the input to parse:
AlphaNumber parsedCh;
int? chValue = null;
if (Enum.TryParse(ch.ToString().ToUpper(), out parsedCh))
{
chValue = (int)parsedCh;
Console.WriteLine(chValue);
}