Gets the numeric value associated with the character at the specified index of the specified string.
- s
- The string containing the Unicode character for which to get the numeric value.
- index
- The index of the Unicode character for which to get the numeric value.
The numeric value associated with the character at the specified index of the specified string.
-or-
-1, if the character at the specified index of the specified string is not a numeric character.
Numeric value is a Unicode character property that applies only to numeric characters, which include fractions, subscripts, superscripts, Roman numerals, currency numerators, encircled numbers, and script-specific digits. For more information on Unicode characters, see the tp://go.microsoft.com/fwlink/?linkid=37123.
If the char object at position index is the first character of a valid surrogate pair, the CharUnicodeInfo.GetNumericValue(string, int) method determines whether the surrogate pair forms a numeric digit, and, if it does, returns its numeric value. For example, the Aegean numbering system consists of code points U+10107 through U+10133. The following example uses the char.ConvertFromUtf32(int) method to instantiate a string that represents each Aegean number. As the output from the example shows, the CharUnicodeInfo.GetNumericValue(string, int) method returns the correct numeric value if it is passed the high surrogate of an Aegean number. However, if it is passed the low surrogate, it considers only the low surrogate in isolation and returns -1.
code reference: System.Globalization.CharUnicodeInfo.GetNumericValue#3