mscorlib 2.0.0.0 4.0.0.0 System.Object System.Collections.Generic.IComparer<T> System.Collections.IComparer To be added.

Derive from this class to provide a custom implementation of the interface for use with collection classes such as the and generic classes.

The difference between deriving from the class and implementing the interface is as follows:

To specify how two objects should be compared by default, implement the interface in your class. This ensures that sort operations will use the default comparison code that you provided.

To define a comparer to use instead of the default comparer, derive from the class. You can then use this comparer in sort operations that take a comparer as a parameter.

The object returned by the property uses the generic interface (IComparable<T> in C#, IComparable(Of T) in Visual Basic) to compare two objects. If type does not implement the generic interface, the property returns a that uses the interface.

Provides a base class for implementations of the generic interface.

- Constructor
  2.0.0.0
  4.0.0.0
  To be added.

  Initializes a new instance of the class.

- Method
  2.0.0.0
  4.0.0.0
  System.Int32 `` `` To be added. To be added. To be added. To be added. To be added.
- Method
  4.0.0.0
  System.Collections.Generic.Comparer<T> `` To be added. To be added. To be added. To be added.
- Property
  2.0.0.0
  4.0.0.0
  System.Collections.Generic.Comparer<T> To be added.

  The returned by this property uses the generic interface (IComparable<T> in C#, IComparable(Of T) in Visual Basic) to compare two objects. If type does not implement the generic interface, this property returns a that uses the interface.

  Returns a default sort order comparer for the type specified by the generic argument.

- Method
  2.0.0.0
  4.0.0.0
  System.Int32 `` ``

  This method is a wrapper for the method, so must be cast to the type specified by the generic argument of the current instance. If it cannot be cast to , an is thrown.

  Comparing null with any reference type is allowed and does not generate an exception. When sorting, null is considered to be less than any other object.

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

  A signed integer that indicates the relative values of and , as shown in the following table.

  Value

  Meaning

  Less than zero

  is less than .

  Zero

  equals .

  Greater than zero

  is greater than .

  The first object to compare. The second object to compare.