In C#, Char.IsAsciiDigit returns true only for the ten ASCII digits '0'–'9'.
Unlike IsDigit, it rejects non-ASCII decimal digits. These ASCII helpers are available in .NET 7 and later. On older runtimes, use range checks such as c >= '0' && c <= '9'.
This is a static member of System.Char. You call it with the type name, such as Char.IsAsciiDigit(...) or char.IsAsciiDigit(...). A char holds one 16-bit UTF-16 code unit.
Syntax
Pass a character expected to be 0–9.
C#
bool ok = Char.IsAsciiDigit('5');
Call
What it does
Char.IsAsciiDigit(c)
True for ASCII 0–9.
Equivalent to c >= '0' && c <= '9'.
Library declarations
C#
public static bool IsAsciiDigit(char c);
Parameters
Parameter
Description
c
Character to test.
Return Value
Return Value
Description
true
ASCII digit.
false
Anything else.
C# Examples
Example 1 — ASCII Digits
Test 5 and A.
C#
using System;
class Program {
static void Main() {
Console.WriteLine(Char.IsAsciiDigit('5'));
Console.WriteLine(Char.IsAsciiDigit('A'));
}
}
Output
True
False
How It Works
Five passes. ASCII digit.
Letter fails. A is not a digit.
.NET 7+. Newer helper.
Strict 0–9. No other scripts.
Example 2 — Same for ASCII
Compare helpers on ASCII 7.
C#
using System;
class Program {
static void Main() {
char c = '7';
Console.WriteLine(Char.IsAsciiDigit(c));
Console.WriteLine(Char.IsDigit(c));
}
}
Output
True
True
How It Works
Both true. ASCII digits satisfy both APIs.
Difference elsewhere. Non-ASCII digits diverge.
Pick strictness. ASCII-only vs Unicode digits.
Same sample. Character 7 in both calls.
Example 3 — All ASCII Digits
Validate a numeric code string.
C#
using System;
class Program {
static void Main() {
string code = "2048";
bool ok = true;
foreach (char ch in code) {
if (!Char.IsAsciiDigit(ch)) { ok = false; break; }
}
Console.WriteLine(ok);
}
}
Output
True
How It Works
Four digits. 2048 is ASCII digits only.
Loop validate. Fail on the first bad char.
True result. Entire string passes.
Protocol friendly. Typical for PIN-like ASCII fields.
Frequently Asked Questions
For 0–9 yes; IsDigit also allows other Unicode decimal digits.