Comparer Class Compares two objects for equivalence, where string comparisons are case-sensitive.
using System;
using System.Collections;
using System.Globalization;
public class SamplesComparer {
public static void Main() {
String str1 = "abc";
String str2 = "Abc";
Console.WriteLine( "Comparing {0} and {1}", str1, str2 );
Console.WriteLine( Comparer.DefaultInvariant.Compare( str1, str2 ) );
Comparer myCompIntl = new Comparer( new CultureInfo( "es-ES", false ) );
Console.WriteLine( myCompIntl.Compare( str1, str2 ) );
Comparer myCompTrad = new Comparer( new CultureInfo( 0x040A, false ) );
Console.WriteLine( myCompTrad.Compare( str1, str2 ) );
}
}
Related examples in the same category