C# Char IsSurrogate() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Char

Definition

In C#, a char is one UTF-16 code unit. Characters beyond the Basic Multilingual Plane need two chars: a high surrogate and a low surrogate.

Char.IsSurrogate returns true if a code unit is either kind of surrogate. Ordinary letters like 'A' return false.

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

Syntax

Pass a single char (one code unit) to test.

C#
bool ok = Char.IsSurrogate(c);
CallWhat it does
Char.IsSurrogate(c)True if c is any surrogate.
Char.IsSurrogate(s, i)Tests s[i].

Use IsHighSurrogate / IsLowSurrogate / IsSurrogatePair for more detail.

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

Parameters

ParameterDescription
cCode unit to test.
s, indexOptional string index overload.

Return Value

Return ValueDescription
trueHigh or low surrogate.
falseNot a surrogate.

C# Examples

Example 1 — Letter Is Not Surrogate

Show that A is not a surrogate.

C#
using System;

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

How It Works

  1. BMP letter. A fits in one char.
  2. Not surrogate. IsSurrogate is false.
  3. Not high. IsHighSurrogate also false.
  4. Everyday text. Most letters never need surrogates.

Example 2 — Surrogate From Emoji String

Inspect the first code unit of a non-BMP character.

C#
using System;

class Program {
    static void Main() {
        string emoji = "\U0001F600"; // 😀
        char first = emoji[0];
        Console.WriteLine("len: " + emoji.Length);
        Console.WriteLine("surrogate: " + Char.IsSurrogate(first));
        Console.WriteLine("high: " + Char.IsHighSurrogate(first));
    }
}

How It Works

  1. Two chars. The emoji needs a surrogate pair.
  2. First unit. Index 0 is the high surrogate.
  3. IsSurrogate true. It is a surrogate code unit.
  4. IsHigh true. Confirms which half you have.

Example 3 — Count Surrogate Units

Count how many surrogate code units appear.

C#
using System;

class Program {
    static void Main() {
        string s = "A\U0001F600B";
        int n = 0;
        foreach (char ch in s) {
            if (Char.IsSurrogate(ch)) n++;
        }
        Console.WriteLine(n);
    }
}

How It Works

  1. Mixed string. Letters plus one emoji.
  2. Two surrogates. High and low units.
  3. Letters ignored. A and B are not surrogates.
  4. Unit count. Not the same as counting visible glyphs.

Frequently Asked Questions

A UTF-16 code unit used in pairs to encode Unicode beyond U+FFFF.
No.
Many emoji need a high and low surrogate—two chars.
IsHighSurrogate, IsLowSurrogate, IsSurrogatePair.
Only when working with non-BMP characters carefully.

Next: IsSurrogatePair()

Return true when two characters form a valid UTF-16 surrogate pair with System.Char.

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

8 people found this page helpful