Mono Class Library: System.Single Overview | Members

System.Single.CompareTo Method

Returns the sort order of the current instance compared to the specified object .

public int CompareTo (object value)

Parameters

value
The object to compare to the current instance.

Returns

The return value is a negative number, zero, or a positive number reflecting the sort order of the current instance as compared to value. For non-zero return values, the exact value returned by this method is unspecified. The following table defines the return value:

Return ValueDescription
Any negative number

Current instance < value.

-or-

Current instance is a NaN and value is not a NaN and is not a null reference.

Zero

Current instance == value .

-or-

Current instance and value are both NaN, positive infinity, or negative infinity.

A positive number

Current instance > value.

-or-

value is a null reference.

-or-

Current instance is not a NaN and value is a NaN.

Exceptions

TypeReason
ArgumentExceptionvalue is not a null reference and is not of type float.

Remarks

Note: This method is implemented to support the IComparable interface. Note that, although a NaN is not considered to be equal to another NaN (even itself), the IComparable interface requires that A.CompareTo(A) return zero.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0