mscorlib 4.0.0.0

The interface enables you to implement customized comparisons for collection members. That is, you can define precisely what it means for one collection object to precede, follow, or occur in the same position in the sort order as a second collection object. You can then specify that this definition be used with a collection type that accepts the interface.

The interface has a single member, , which determines whether the current collection object is less than, equal to, or greater than a second object in the sort order. The actual comparison of the members or elements in the current instance with those in a second object is performed by an interface implementation, which contains the definition of your custom comparison.

The interface supports only structural comparisons for sorting or ordering. The interface supports custom comparisons for structural equality.

The .NET Framework provides two default comparers. One is returned by the property; the other is returned by the property.

The generic tuple classes (, , , and so on) and the class provide explicit implementations of the interface. By casting (in C#) or converting (in Visual Basic) the current instance of an array or tuple to an interface value and providing your implementation as an argument to the method, you can define a custom sort order for the array or collection. However, you do not call the method directly in most cases. Instead, the method is called by sorting methods such as . In this case, you define your implementation and pass it as an argument to a sorting method or collection object's class constructor. The method with your custom comparer is then called automatically whenever the collection is sorted.

Supports the structural comparison of collection objects.

- Method
  4.0.0.0
  System.Int32 `` ``

  The method supports custom structural comparison and sorting of array and tuple objects. The method calls the object's method to compare individual array elements or tuple components, starting with the first element or component. The individual calls to end and the method returns a value when one of the following conditions becomes true:

  The method returns -1.

  The method returns 1.

  The method is called for the last element or component in the collection object.

  Determines whether the current collection object precedes, occurs in the same position as, or follows another object in the sort order.

  An integer that indicates the relationship of the current collection object to , as shown in the following table.

  Return value

  Description

  -1

  The current instance precedes .

  0

  The current instance and are equal.

  1

  The current instance follows .

  The object to compare with the current instance. An object that compares members of the current collection object with the corresponding members of .