C# Char IsPunctuation() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Char

Definition

In C#, Char.IsPunctuation returns true for Unicode punctuation categories (connectors, dashes, quotes, and other punctuation).

Letters, digits, and ordinary spaces return false.

This is a static member of System.Char. You call it with the type name, such as Char.IsPunctuation(...) or char.IsPunctuation(...). A char holds one 16-bit UTF-16 code unit.

Syntax

Pass the character to test.

C#
bool ok = Char.IsPunctuation(',');
CallWhat it does
Char.IsPunctuation(c)True if c is punctuation.
Char.IsPunctuation(s, i)Tests s[i].

Some symbols (currency, math) are IsSymbol instead of IsPunctuation.

Library declarations
C#
public static bool IsPunctuation(char c);
public static bool IsPunctuation(string s, int index);

Parameters

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

Return Value

Return ValueDescription
truePunctuation.
falseNot punctuation.

C# Examples

Example 1 — Comma and Period

Test common punctuation.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine(Char.IsPunctuation(','));
        Console.WriteLine(Char.IsPunctuation('.'));
        Console.WriteLine(Char.IsPunctuation('A'));
    }
}

How It Works

  1. Comma. Classic punctuation.
  2. Period. Also punctuation.
  3. Letter fails. A is not punctuation.
  4. Quick trio. Shows typical true/false outcomes.

Example 2 — Dollar Is Symbol

Contrast punctuation with a currency symbol.

C#
using System;

class Program {
    static void Main() {
        char dollar = '$';
        Console.WriteLine("punct: " + Char.IsPunctuation(dollar));
        Console.WriteLine("symbol: " + Char.IsSymbol(dollar));
    }
}

How It Works

  1. Dollar sign. Treated as a symbol.
  2. Not punctuation. IsPunctuation is false.
  3. IsSymbol true. Use the matching helper.
  4. Category matters. Unicode classes are finer than “special character.”

Example 3 — Remove Punctuation

Build a string without punctuation marks.

C#
using System;

class Program {
    static void Main() {
        string raw = "Hello, world!";
        string keep = "";
        foreach (char ch in raw) {
            if (!Char.IsPunctuation(ch)) keep += ch;
        }
        Console.WriteLine(keep);
    }
}

How It Works

  1. Greeting text. Contains comma and exclamation.
  2. Filter out punct. Keep everything else, including spaces.
  3. Hello world. Punctuation removed.
  4. Letters stay. Alphanumeric content is preserved.

Frequently Asked Questions

Yes.
Usually no—it is a symbol. Check IsSymbol.
No.
Many quote characters are punctuation categories.
Yes.

Next: IsSeparator()

Return true when the character is a Unicode separator with System.Char.

IsSeparator() 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