C# Char IsSurrogatePair() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Char

Definition

In C#, Char.IsSurrogatePair returns true when two adjacent code units form a valid high+low surrogate pair.

Use it before calling ConvertToUtf32 on a string index, or when scanning text that may contain emoji.

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

Syntax

Pass two chars, or a string and starting index.

C#
bool ok = Char.IsSurrogatePair(high, low);
bool also = Char.IsSurrogatePair(text, index);
CallWhat it does
Char.IsSurrogatePair(high, low)True if high+low is a valid pair.
Char.IsSurrogatePair(s, i)True if s[i], s[i+1] form a pair.

False when order is wrong or either unit is not a surrogate.

Library declarations
C#
public static bool IsSurrogatePair(char highSurrogate, char lowSurrogate);
public static bool IsSurrogatePair(string s, int index);

Parameters

ParameterDescription
highSurrogate, lowSurrogateExpected high then low.
s, indexString and start index for a possible pair.

Return Value

Return ValueDescription
trueValid surrogate pair.
falseNot a valid pair.

C# Examples

Example 1 — Emoji Pair

Confirm an emoji string starts with a pair.

C#
using System;

class Program {
    static void Main() {
        string emoji = "\U0001F600";
        Console.WriteLine(Char.IsSurrogatePair(emoji, 0));
        Console.WriteLine(emoji.Length);
    }
}

How It Works

  1. Pair at 0. High and low present.
  2. Length 2. Two UTF-16 units.
  3. Ready for UTF-32. Safe to convert.
  4. One glyph. Still one visible character conceptually.

Example 2 — Low Then High Fails

Swap units and watch the check fail.

C#
using System;

class Program {
    static void Main() {
        string emoji = "\U0001F600";
        char high = emoji[0];
        char low = emoji[1];
        Console.WriteLine(Char.IsSurrogatePair(high, low));
        Console.WriteLine(Char.IsSurrogatePair(low, high));
    }
}

How It Works

  1. Correct order. High then low works.
  2. Swapped fails. Low then high is invalid.
  3. Order matters. Pair rules are strict.
  4. Do not reverse. Keep the natural string order.

Example 3 — Pair to UTF-32

Validate then convert to a code point.

C#
using System;

class Program {
    static void Main() {
        string emoji = "\U0001F600";
        if (Char.IsSurrogatePair(emoji, 0)) {
            int cp = Char.ConvertToUtf32(emoji, 0);
            Console.WriteLine(cp.ToString("X"));
        }
    }
}

How It Works

  1. Guard first. IsSurrogatePair before convert.
  2. UTF-32 value. ConvertToUtf32 yields the code point.
  3. Hex print. 1F600 is the emoji code.
  4. Safe path. Avoids exceptions from bad pairs.

Frequently Asked Questions

A high surrogate followed by a low surrogate.
Yes. Low then high is false.
ConvertToUtf32 / ConvertFromUtf32.
Yes—ensure index+1 exists.
IsSurrogatePair is false for ordinary letters.

Next: IsSymbol()

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

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

9 people found this page helpful