C# StringComparer Ordinal
Description
StringComparer Ordinal
gets a StringComparer object
that performs a case-sensitive ordinal string comparison.
Syntax
StringComparer.Ordinal
has the following syntax.
public static StringComparer Ordinal { get; }
Example
using System;//from w w w. ja v a 2 s . co m
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Threading;
class Sample
{
public static void Main()
{
List<string> list = new List<string>();
StringComparer invCmp = StringComparer.Ordinal;
string capitalLetterI = "I";
string smallLetterI = "i";
string smallLetterDotlessI = "\u0131";
list.Add(capitalLetterI);
list.Add(smallLetterI);
list.Add(smallLetterDotlessI);
list.Sort(invCmp);
}
}
The code above generates the following result.