Char - IsHighSurrogate

Indicates whether the specified object is a high surrogate.

Try it

public static void Main()
{
    char [] input = new char[] { 'a', '\uD800', '\uDC00', 'z' };

    Console.WriteLine("Is each of the following characters a high surrogate?");
	
    for (int i = 0; i < input.Length; i++)
    {
		// C# Extension Method: Char - IsHighSurrogate
		var result = input[i].IsHighSurrogate();
		
        Console.WriteLine("input[{0}] = {1} ", i, result);
    }
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     Indicates whether the specified  object is a high surrogate.
    /// </summary>
    /// <param name="c">The Unicode character to evaluate.</param>
    /// <returns>
    ///     true if the numeric value of the  parameter ranges from U+D800 through U+DBFF; otherwise, false.
    /// </returns>
    public static Boolean IsHighSurrogate(this Char c)
    {
        return Char.IsHighSurrogate(c);
    }
}