August 2003
Intermediate to advanced
928 pages
32h 1m
English
Comparer
The Comparer class is
used to compare two objects
of the same type. The Compare( ) method takes two
objects. If the first object is less than the second, a negative
value is returned. If the first object is greater than the second, a
positive value is returned. If the objects are equal, zero is
returned. The comparisons of strings are case-sensitive. For
case-insensitive string comparisons, use
CaseInsensitiveComparer. You can obtain a standard
comparer that uses the
System.Globalization.InvariantCulture rules for
string comparisons by using the
CaseInsensitiveComparer instance returned from the
static DefaultInvariant property.
public sealed class Comparer : IComparer { // Public Constructors public Comparer(System.Globalization.CultureInfoculture); // Public Static Fields public static readonly Comparer Default; // =System.Collections.Comparer public static readonly Comparer DefaultInvariant; // =System.Collections.Comparer // Public Instance Methods public int Compare(objecta, objectb); // implements IComparer }