O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Comparer

Synopsis

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.

public sealed class Comparer : IComparer {
// Public Static Fields
   public static readonly field Comparer Default;                // =System.Collections.Comparer
                  // Public Instance Methods
   public method int Compare(object a, object b);               // implements IComparer
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required