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(',');
Call
What 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
Parameter
Description
c
Character to test.
s, index
Optional string index overload.
Return Value
Return Value
Description
true
Punctuation.
false
Not 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'));
}
}
Output
True
True
False
How It Works
Comma. Classic punctuation.
Period. Also punctuation.
Letter fails. A is not punctuation.
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));
}
}
Output
punct: False
symbol: True
How It Works
Dollar sign. Treated as a symbol.
Not punctuation. IsPunctuation is false.
IsSymbol true. Use the matching helper.
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);
}
}
Output
Hello world
How It Works
Greeting text. Contains comma and exclamation.
Filter out punct. Keep everything else, including spaces.