System.Collections.IStructuralComparable.CompareTo Method

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

Syntax

public int CompareTo (object other, IComparer comparer)

Parameters

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

Returns

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

-1

The current instance precedes other.

0

The current instance and other are equal.

1

The current instance follows other.

Remarks

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

Requirements

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