Char.IsSurrogatePair Method (String, Int32)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Indicates whether two adjacent Char objects at a specified position in a string form a surrogate pair.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

static member IsSurrogatePair : 
        s:string *
        index:int -> bool


Type: System.String

A string.

Type: System.Int32

The starting position of the pair of characters to evaluate within s.

Return Value

Type: System.Boolean

true if the s parameter includes adjacent characters at positions index and index + 1, and the numeric value of the character at position index ranges from U+D800 through U+DBFF, and the numeric value of the character at position index+1 ranges from U+DC00 through U+DFFF; otherwise, false.

Exception Condition

s is null.


index is not a position within s.

Ordinarily, a single character is represented by a single 16-bit Unicode code unit. UTF-16 encoding also supports surrogate pairs, which allow a single abstract character to be represented by two 16-bit code units. The first code unit, whose value can range from U+D800 to U+DBFF, is the high surrogate. The second code unit, whose value can range from U+DC00 to U+DFFF, is the low surrogate. Individual surrogate code points have no interpretation of their own. For more information about surrogates and the Unicode Standard, see the Unicode home page.

The following code example demonstrates the IsHighSurrogate, IsLowSurrogate, and IsSurrogatePair methods.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top