he method Char.GetNumericValue
retrieves the numeric value of a specific char
.
However, it's important to note a few things about this method:
- It's designed to work on individual
char
values, not on lists or strings. - The method returns a
double
, because some characters can represent fractional values (like the character for a half, '½', which would return0.5
). - If the character does not have a numeric value (like 'a' or '!'), the method returns
-1
.
For example:
- If
charList[0]
is '5', thenChar.GetNumericValue(charList[0])
will return5.0
. - If
charList[0]
is 'a', thenChar.GetNumericValue(charList[0])
will return-1.0
.
- If