C# Char IsHighSurrogate(Char)

Description

Char IsHighSurrogate(Char) indicates whether the specified Char object is a high surrogate.

Syntax

Char.IsHighSurrogate(Char) has the following syntax.


public static bool IsHighSurrogate(
  char c
)

Parameters

Char.IsHighSurrogate(Char) has the following parameters.

  • c - The Unicode character to evaluate.

Returns

Char.IsHighSurrogate(Char) method returns true if the numeric value of the c parameter ranges from U+D800 through U+DBFF; otherwise, false.

Example

The following code example demonstrates the IsHighSurrogate method.


using System;/*from www . j a va  2  s. com*/

class Sample 
{
    public static void Main() 
    {
        char cHigh = '\uD800';
        char cLow  = '\uDC00';
        string s1  = new String(new char[] {'a', '\uD800', '\uDC00', 'z'});
    
        Console.WriteLine("A1) cLow?  - {0}", Char.IsHighSurrogate(cLow));
        Console.WriteLine("A2) cHigh? - {0}", Char.IsHighSurrogate(cHigh));
        Console.WriteLine("A3) s1[0]? - {0}", Char.IsHighSurrogate(s1, 0));
        Console.WriteLine("A4) s1[1]? - {0}", Char.IsHighSurrogate(s1, 1));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version