C# Comparer DefaultInvariant
Description
Comparer DefaultInvariant
represents an instance of
Comparer that is associated with CultureInfo.InvariantCulture. This
field is read-only.
Syntax
Comparer.DefaultInvariant
has the following syntax.
public static readonly Comparer DefaultInvariant
Example
The following code example shows how Compare returns different values depending on the culture associated with the Comparer.
using System;/* ww w. ja v a 2 s . c om*/
using System.Collections;
using System.Globalization;
public class SamplesComparer {
public static void Main() {
String str1 = "abc";
String str2 = "aabc";
Console.WriteLine(Comparer.DefaultInvariant.Compare( str1, str2 ) );
Comparer myCompIntl = new Comparer( new CultureInfo( "es-ES", false ) );
Console.WriteLine(myCompIntl.Compare( str1, str2 ) );
}
}
The code above generates the following result.