C# Char IsSeparator() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Char

Definition

In C#, Char.IsSeparator returns true for Unicode separator characters (space, line, and paragraph separators).

A plain space is a separator. Tab and newline are whitespace/control but are not separators in this API.

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

Syntax

Pass the character to test.

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

Prefer IsWhiteSpace when you want tabs and newlines included.

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

Parameters

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

Return Value

Return ValueDescription
trueSeparator character.
falseNot a separator.

C# Examples

Example 1 — Space Is Separator

Test space versus a letter.

C#
using System;

class Program {
    static void Main() {
        Console.WriteLine(Char.IsSeparator(' '));
        Console.WriteLine(Char.IsSeparator('x'));
    }
}

How It Works

  1. Space separator. Ordinary space matches.
  2. Letter x. Not a separator.
  3. True/False. Simple classification printout.
  4. Category Zs. Space sits in separator classes.

Example 2 — Tab Is Not Separator

Compare IsSeparator with IsWhiteSpace on tab.

C#
using System;

class Program {
    static void Main() {
        char tab = '\t';
        Console.WriteLine("separator: " + Char.IsSeparator(tab));
        Console.WriteLine("whitespace: " + Char.IsWhiteSpace(tab));
    }
}

How It Works

  1. Tab contrast. Separators exclude tab.
  2. Still whitespace. IsWhiteSpace is true.
  3. API nuance. Names sound similar but categories differ.
  4. Pick IsWhiteSpace. When trimming general blanks, prefer it.

Example 3 — Count Spaces

Count separator characters in a phrase.

C#
using System;

class Program {
    static void Main() {
        string s = "a b  c";
        int n = 0;
        foreach (char ch in s) {
            if (Char.IsSeparator(ch)) n++;
        }
        Console.WriteLine(n);
    }
}

How It Works

  1. Three spaces. Including a double gap.
  2. Loop tally. Increment per separator.
  3. Letters ignored. a, b, c do not count.
  4. Space focus. Tabs would not add here.

Frequently Asked Questions

Yes.
No. Tab is whitespace/control, not a separator category.
Usually no for ; use IsWhiteSpace for line breaks.
Use IsWhiteSpace for general blank detection; IsSeparator for Unicode separator categories only.
Yes.

Next: IsSurrogate()

Return true when the character is a high or low UTF-16 surrogate with System.Char.

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

7 people found this page helpful