Console.ReadKey returns a ConsoleKeyInfo object - refer;
Console.ReadKey Method (System)[
^]
The above reference will also give you an example but the short answer is as follows;
ConsoleKeyInfo ck = Console.ReadKey();
if(ck.Key.ToString().ToUpper() != "A" && ck.Key.ToString().ToUpper() != "B" && ck.Key.ToString.ToUpper() != "C")
{
Console.WriteLine("Invalid entry. Please try again");
}
You can also use Regular expressions for this - refer;
Regex Class (System.Text.RegularExpressions)[
^] Which would be faster.
Using chars is more difficult but still possible, but you need to either convert it to a string, or use the 16 bit numeric value when comparing - (a = 97, A = 65 etc) as this is what is actually stored - refer;
Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion[
^]
EDIT: In the above comments it was pointed out that there is a method ToUpper available for the char data type, but you cannot use char.ToUpper(), you need to pass in the char for the Framework to convert it.
If you do want to use this method the above code would be changed as follows;
char question = Console.ReadKey().KeyChar;
if(char.ToUpper(question) != 'A' && char.ToUpper(question) != 'B' && char.ToUpper(question) != 'C')
{
Console.WriteLine("Invalid entry. Please try again");
}
Kind Regards