String - IsLowSurrogate
Indicates whether the object at the specified position in a string is a low surrogate.
public static void Main() { string input = new String(new char[] { 'a', '\uD800', '\uDC00', 'z' }); Console.WriteLine("Is each of the following characters a low surrogate?"); for (int i = 0; i < input.Length; i++) { // C# Extension Method: String - IsLowSurrogate var result = input.IsLowSurrogate(i); Console.WriteLine("input[{0}] = {1} ", i, result); } }
View Source
using System; public static partial class Extensions { /// <summary> /// Indicates whether the object at the specified position in a string is a low surrogate. /// </summary> /// <param name="s">A string.</param> /// <param name="index">The position of the character to evaluate in .</param> /// <returns> /// true if the numeric value of the specified character in the parameter ranges from U+DC00 through U+DFFF; /// otherwise, false. /// </returns> public static Boolean IsLowSurrogate(this String s, Int32 index) { return Char.IsLowSurrogate(s, index); } }