How to convert a char from IO stream into an int please
-
Hi all, I'm having some trouble getting with this: char temp = System.Console.ReadKey(); //Throws an exception So I tried System.Console.ReadKey().KeyChar which returns the ascii value of the key I entered... Basically I need to get a key that falls in the range of 0-10 There's a validation line that handles if temp > 0 || temp < 10... but I can't get the character to convert into an int properly. Thanks Humble
-
Hi all, I'm having some trouble getting with this: char temp = System.Console.ReadKey(); //Throws an exception So I tried System.Console.ReadKey().KeyChar which returns the ascii value of the key I entered... Basically I need to get a key that falls in the range of 0-10 There's a validation line that handles if temp > 0 || temp < 10... but I can't get the character to convert into an int properly. Thanks Humble
if (Char.IsNumeric(Readkey().KeyChar))
should tell you if it's a number of not.
Deja View - the feeling that you've seen this post before.
-
if (Char.IsNumeric(Readkey().KeyChar))
should tell you if it's a number of not.
Deja View - the feeling that you've seen this post before.
Yeah, I've got the validation portion down... I need to get the character, which if entered proprly is an integer number, and convert it into an integer for processing.
-
Yeah, I've got the validation portion down... I need to get the character, which if entered proprly is an integer number, and convert it into an integer for processing.
Probably an easier way but this seems to work: int val = Convert.ToInt32(e.KeyChar.ToString()); Good Luck!
“You can't teach people to be lazy - either they have it, or they don't.” -Dagwood Bumbstead