ConsoleKeyInfo CKI = Console.ReadKey(true);
CKI.KeyChar is the unicode equivalent of the character input
So if I’d press ‘1’ in the console prompt CKI.KeyChar would be 49, not the value ‘1’.
How do I get the value ‘1’?
I know its a devious way of getting the input, but its the way my teacher wants it so I cant do it otherwise.
Edit: I need the value that the user gave, because I’m going to have to check if its less than 9
Use the
.KeyCharproperty and compare withChar.IsNumber.To get the numeric equivalent, you can use
Int32.ParseorInt32.TryParse:Test Application: