How to convert char to int? [duplicate]

I’m surprised nobody has mentioned the static method built right into System.Char

int val = (int)Char.GetNumericValue('8');
// val == 8

Leave a Comment