C# Char IsNumber() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Char

Definition

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

ParameterDescription
cCharacter to test.
s, indexOptional string index overload.

Return Value

Return ValueDescription
trueUnicode numeric character.
falseNot 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'));
    }
}

How It Works

  1. Digit eight. Decimal digits are numbers.
  2. Letter x. Not numeric.
  3. Boolean output. True then False.
  4. 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));
    }
}

How It Works

  1. Special numeric. ½ belongs to a number category.
  2. Not Nd digit. IsDigit stays false.
  3. Contrast lesson. Same character, two helpers, two answers.
  4. 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);
    }
}

How It Works

  1. Mixed glyphs. Letters plus digit plus fraction.
  2. Two matches. 1 and ½ count.
  3. Letters skipped. A and B are not numbers.
  4. 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.
Prefer IsDigit or IsAsciiDigit.
No. It only classifies a single character.
Yes.

Next: IsPunctuation()

Return true when the character is Unicode punctuation with System.Char.

IsPunctuation() 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.

14 people found this page helpful