Returns the numeric value associated with the specified Unicode character.
- c
- A Unicode character.
A double representing the numeric value associated with c if and only if c has an associated numeric value; otherwise, -1.0.
A character has an associated numeric value if and only if it is a member of one of the following categories in System.Globalization.UnicodeCategory: System.Globalization.UnicodeCategory.DecimalDigitNumber, System.Globalization.UnicodeCategory.LetterNumber, or System.Globalization.UnicodeCategory.OtherNumber.
The following example demonstrates the char.GetNumericValue(char) method.
C# Example
using System; public class GetNumericValueExample { public static void Main() { Char[] cAry = {'8', 'V', Convert.ToChar(0X00BC)}; //Unicode U+00BC is the code point for the character //representation of 1/4 foreach(Char c in cAry) { Console.Write("Numeric value of Unicode " + "character {0} ", c); Console.WriteLine(" is {0}", Char.GetNumericValue(c)); } } }The output is
Numeric value of Unicode character 8 is 8
Numeric value of Unicode character V is -1
Numeric value of Unicode character 1/4 is 0.25
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0