In C#, Char.IsNumber returns true for characters in Unicode number categories—not only decimal digits, but also other numeric forms such as some fractions.
If you only want 0–9 style decimal digits, prefer IsDigit (or IsAsciiDigit).
This is a static member of System.Char. You call it with the type name, such as Char.IsNumber(...) or char.IsNumber(...). A char holds one 16-bit UTF-16 code unit.
Syntax
Pass the character to classify.
C#
bool ok = Char.IsNumber('5');
Call
What it does
Char.IsNumber(c)
True for numeric characters.
Char.IsNumber(s, i)
Tests s[i].
All IsDigit characters are IsNumber, but not vice versa.
Library declarations
C#
public static bool IsNumber(char c);
public static bool IsNumber(string s, int index);
Parameters
Parameter
Description
c
Character to test.
s, index
Optional string index overload.
Return Value
Return Value
Description
true
Unicode numeric character.
false
Not numeric.
C# Examples
Example 1 — Digit Is a Number
Show that ASCII digits pass IsNumber.
C#
using System;
class Program {
static void Main() {
Console.WriteLine(Char.IsNumber('8'));
Console.WriteLine(Char.IsNumber('x'));
}
}
Output
True
False
How It Works
Digit eight. Decimal digits are numbers.
Letter x. Not numeric.
Boolean output. True then False.
Baseline. Confirms everyday digit behavior.
Example 2 — Vulgar Fraction
½ is a number but not a digit.
C#
using System;
class Program {
static void Main() {
char half = '\u00BD';
Console.WriteLine("IsNumber: " + Char.IsNumber(half));
Console.WriteLine("IsDigit: " + Char.IsDigit(half));
}
}
Output
IsNumber: True
IsDigit: False
How It Works
Special numeric. ½ belongs to a number category.
Not Nd digit. IsDigit stays false.
Contrast lesson. Same character, two helpers, two answers.
Validation tip. Decide which definition your app needs.
Example 3 — Count Numeric Chars
Count IsNumber hits in a short string.
C#
using System;
class Program {
static void Main() {
string s = "A1½B";
int n = 0;
foreach (char ch in s) {
if (Char.IsNumber(ch)) n++;
}
Console.WriteLine(n);
}
}
Output
2
How It Works
Mixed glyphs. Letters plus digit plus fraction.
Two matches. 1 and ½ count.
Letters skipped. A and B are not numbers.
Wider net. IsDigit alone would count only 1.
Frequently Asked Questions
Yes. Decimal digits are a subset of numbers.
No. Fractions and other numeric forms may be numbers only.