Sorry, I missed this originally. To query the user for input on the console, check for valid input and convert the letter to a number do:
Code:
public static int requestInputAndConvertToNumber()
{
string input = null;
while(true)
{
//Prompt user
Console.Write("Enter number: ");
//Get input from the user
input = Console.ReadLine(); //Also ReadKey might be useful
//Check to see if this input is in the dictionary; if so store the numerical value
// in result
int result = 0;
bool inDictionary = numberMap.TryGetValue(input, out result);
if( !inDictionary )
{
//Complain
Console.WriteLine("Hey! That number wasn't valid!");
continue; //Restart the loop to try again
}
//Otherwise return the result (the corresponding integer)
return result;
}
}
Hopefully no bugs this time. :-)
Does that make sense? If not, push back!