Is there something like java Character.digit (char ch, int radix) in C #?

Character.digit(char ch, int radix) 

Returns the numeric value of the character ch in the specified radius.

Is there an equivalent function in C #?

+4
source share
1 answer

I don't know about the direct equivalent. The closest match I can find is

 Convert.ToInt32(string s, int baseFrom); 

So you can convert your char to a string, and then pass it to the function above to get int32 or Int16 or Byte, or you want to process it:

 char c = 'F'; int digit = Convert.ToInt32(c.ToString(),16); 

Note. Convert will throw a FormatException if char is not a digit

+9
source

Source: https://habr.com/ru/post/1286515/


All Articles