C# Char IsSurrogate(String, Int32)
Description
Char IsSurrogate(String, Int32)
indicates whether
the character at the specified position in a specified string has a surrogate
code unit.
Syntax
Char.IsSurrogate(String, Int32)
has the following syntax.
public static bool IsSurrogate(
string s,
int index
)
Parameters
Char.IsSurrogate(String, Int32)
has the following parameters.
s
- A string.index
- The position of the character to evaluate in s.
Returns
Char.IsSurrogate(String, Int32)
method returns true if the character at position index in s is a either a high surrogate or
a low surrogate; otherwise, false.
Example
The following code example demonstrates IsSurrogate.
/*from w ww . j a v a2 s .c o 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(str, 0)); // Output: "True"
}
}
The code above generates the following result.