IComparer.Compare Method
Compares two objects and returns a value indicating whether the first object is less than, equal to, or greater than the second object.
Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Syntax
public int Compare (
Objectx,
Objecty
)
Parameters
- x
The first object you want to compare. - y
The second object you want to compare.
Return Value
One of the values listed in the following table.
Value | Condition |
---|---|
Less than 0 (zero) | x is less than y |
Zero | x equals y |
Greater than zero | x is greater than y |
Remarks
Using IComparable, you can compare a null reference with any type of object without generating an exception. Note that during a sorting operation, a null reference is considered to be less than any other object.
Version Information
Available in the .NET Micro Framework versions 2.0, 2.5, 3.0, 4.0, and 4.1.
See Also
Reference
IComparer Interface
IComparer Members
System.Collections Namespace