C# Char IsAscii() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Char

Definition

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');
CallWhat 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

ParameterDescription
cCharacter to test.

Return Value

Return ValueDescription
trueASCII code unit.
falseAbove 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('é'));
    }
}

How It Works

  1. A is ASCII. Code unit 65 is in range.
  2. é is not. Its code unit is above 127.
  3. .NET 7+ API. Requires a recent runtime.
  4. 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);
    }
}

How It Works

  1. Digit nine. Still an ASCII code unit.
  2. Print code. 57 confirms the numeric value.
  3. True result. IsAscii accepts digits.
  4. 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);
    }
}

How It Works

  1. Mixed word. Café ends with a non-ASCII letter.
  2. Keep ASCII. Append only when IsAscii is true.
  3. é removed. Result is Caf.
  4. Data cleaning. Useful for ASCII-only protocols.

Frequently Asked Questions

Code units 0 through 127.
No.
.NET 7 or later.
No. Any ASCII code unit counts.
Compare (int)c <= 127 or use ranges.

Next: IsAsciiDigit()

Return true for ASCII digits 0–9 only. .NET 7+ with System.Char.

IsAsciiDigit() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

15 people found this page helpful