System.Char.IsNumber Method

Indicates whether the specified Unicode character is categorized as a number.

Syntax

public static bool IsNumber (char c)

Parameters

c
The Unicode character to evaluate.

Returns

true if c is a number; otherwise, false.

Remarks

This method determines whether a char is of any numeric Unicode category. In addition to including digits, numbers include characters, fractions, subscripts, superscripts, Roman numerals, currency numerators, and encircled numbers. This method contrasts with the char.IsDigit(char) method, which determines whether a char is a radix-10 digit.

Valid numbers are members of the System.Globalization.UnicodeCategory.DecimalDigitNumber, System.Globalization.UnicodeCategory.LetterNumber, or System.Globalization.UnicodeCategory.OtherNumber category.

The char.IsNumber(char) method assumes that c corresponds to a single linguistic character and checks whether that character represents a number. However, some numbers in the Unicode standard are represented by two char objects that form a surrogate pair. 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 AEGEAN NUMBER ONE. As the output from the example shows, the char.IsNumber(char) method returns false if it is passed either a high surrogate or a low surrogate of this character.

code reference: System.Char.IsNumber#1

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0