System.Globalization.CharUnicodeInfo.GetNumericValue Method

Gets the numeric value associated with the character at the specified index of the specified string.

Syntax

public static double GetNumericValue (string s, int index)

Parameters

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.

Returns

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.

Remarks

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

Requirements

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0