Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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;

Example

[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

[C#] 
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"
    }
}

[C++] 
#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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft