This documentation is archived and is not being maintained.

Char.IsSurrogate Method

Indicates whether a Unicode character is categorized as a surrogate character.

Overload List

Indicates whether the specified Unicode character is categorized as a surrogate character.

[Visual Basic] Overloads Public Shared Function IsSurrogate(Char) As Boolean
[C#] public static bool IsSurrogate(char);
[C++] public: static bool IsSurrogate(__wchar_t);
[JScript] public static function IsSurrogate(Char) : Boolean;

Indicates whether the character at the specified position in a specified string is categorized as a surrogate character.

[Visual Basic] Overloads Public Shared Function IsSurrogate(String, Integer) As Boolean
[C#] public static bool IsSurrogate(string, int);
[C++] public: static bool IsSurrogate(String*, int);
[JScript] public static function IsSurrogate(String, int) : Boolean;


[Visual Basic, C#, C++] The following sample demonstrates IsSurrogate.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of IsSurrogate. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Imports System

Module IsSurrogateSample

    Sub Main()

        ' NOTE: Visual Basic doesn't give us a way to create a 32-bit Unicode 
        ' character composed of two 16-bit surrogate values, so a case where 
        ' IsSurrogate returns True cannot be included in this sample. 

        Console.WriteLine(Char.IsSurrogate("a"c))       ' Output: "False"

    End Sub

End Module

using System;

public class IsSurrogateSample {
    public static void Main() {
        string str = "\U00010F00"; // Unicode values between 0x10000 and 0x10FFF are represented by two 16-bit "surrogate" characters

        Console.WriteLine(Char.IsSurrogate('a'));        // Output: "False"
        Console.WriteLine(Char.IsSurrogate(str, 0));    // Output: "True"

#using <mscorlib.dll>
using namespace System;

int main() {
   // - escape params specifying Unicode not implemented in v7.0

   Console::WriteLine(Char::IsSurrogate('a')); // Output: "False"

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

Char Structure | Char Members | System Namespace