What is the proper way to convert a char to int? This gives 49:
char
int
49
int val = Convert.ToInt32('1'); //int val = Int32.Parse("1"); // Works
I don't want to convert to string and then parse it.
I'm surprised nobody has mentioned the static method built right into System.Char...
System.Char
int val = (int)Char.GetNumericValue('8'); // val == 8
1.4m articles
1.4m replys
5 comments
57.0k users