In C#, Char.IsAscii returns true when a character’s code unit is in the ASCII range 0–127.
It does not ask whether the character is a letter or digit—only whether it fits in classic ASCII. 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.IsAscii(...) or char.IsAscii(...). A char holds one 16-bit UTF-16 code unit.
Syntax
Pass a character; true means code unit ≤ 127.
C#
bool ok = Char.IsAscii('A');
Call
What it does
Char.IsAscii(c)
True if c is ASCII (0–127).
Accented letters like é are outside ASCII.
Library declarations
C#
public static bool IsAscii(char c);
Parameters
Parameter
Description
c
Character to test.
Return Value
Return Value
Description
true
ASCII code unit.
false
Above 127.
C# Examples
Example 1 — Letter Inside ASCII
Test A and an accented letter.
C#
using System;
class Program {
static void Main() {
Console.WriteLine(Char.IsAscii('A'));
Console.WriteLine(Char.IsAscii('é'));
}
}
Output
True
False
How It Works
A is ASCII. Code unit 65 is in range.
é is not. Its code unit is above 127.
.NET 7+ API. Requires a recent runtime.
Range only. No letter/digit judgment here.
Example 2 — Digits Are ASCII
Show that '9' is ASCII.
C#
using System;
class Program {
static void Main() {
char c = '9';
Console.WriteLine(Char.IsAscii(c));
Console.WriteLine((int)c);
}
}
Output
True
57
How It Works
Digit nine. Still an ASCII code unit.
Print code. 57 confirms the numeric value.
True result. IsAscii accepts digits.
Combine filters. Pair with IsAsciiDigit when you need digits only.
Example 3 — Keep ASCII Only
Drop non-ASCII characters from a string.
C#
using System;
class Program {
static void Main() {
string raw = "Café";
string ascii = "";
foreach (char ch in raw) {
if (Char.IsAscii(ch)) ascii += ch;
}
Console.WriteLine(ascii);
}
}