System.Enum.CompareTo Method

Compares this instance to a specified object and returns an indication of their relative values.

Syntax

public int CompareTo (object target)

Parameters

target
An object to compare, or null.

Returns

A signed number that indicates the relative values of this instance and target.

Less than zero

The value of this instance is less than the value of target.

Zero

The value of this instance is equal to the value of target.

Greater than zero

The value of this instance is greater than the value of target.

-or-

target is null.

Exceptions

TypeReason
ArgumentException target and the current instance are not of the same enumeration type.

Remarks

Note: This method is implemented to support the IComparable interface.

Requirements

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