IComparer Interface

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Exposes a method that compares two objects.

Namespace:  System.Collections
Assembly:  mscorlib (in mscorlib.dll)

public interface class IComparer

The IComparer type exposes the following members.

  NameDescription
Public methodCompareCompares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
Top

This interface is used in conjunction with the Array.Sort and Array.BinarySearch methods. It provides a way to customize the sort order of a collection. See the Compare method for notes on parameters and return value.

The default implementation of this interface is the Comparer class. For the generic version of this interface, see IComparer.

Show: