C# Char IsSurrogate(Char)

Description

Char IsSurrogate(Char) indicates whether the specified character has a surrogate code unit.

Syntax

Char.IsSurrogate(Char) has the following syntax.


public static bool IsSurrogate(
  char c
)

Parameters

Char.IsSurrogate(Char) has the following parameters.

  • c - The Unicode character to evaluate.

Returns

Char.IsSurrogate(Char) method returns true if c is either a high surrogate or a low surrogate; otherwise, false.

Example

The following example demonstrates the IsSurrogate method.


//from w  w  w  .j  a  va  2  s  .co m
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"
  }
}

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