Share via


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)

Syntax

'Declaration
Public Interface IComparer
public interface IComparer
public interface class IComparer
type IComparer =  interface end
public interface IComparer

The IComparer type exposes the following members.

Methods

  Name Description
Public method Compare Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.

Top

Remarks

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.

See Also

Reference

System.Collections Namespace