Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Int32.CompareTo Method

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

[Visual Basic]
Public Overridable Function CompareTo( _
   ByVal value As Object _
) As Integer
public virtual int CompareTo(
 object value
public: virtual int CompareTo(
 Object* value
public function CompareTo(
   value : Object
) : int;


An object to compare, or a null reference (Nothing in Visual Basic).

Return Value

A signed number indicating the relative values of this instance and value.

Return Value Description
Less than zero This instance is less than value.
Zero This instance is equal to value.
Greater than zero This instance is greater than value.


value is a null reference (Nothing in Visual Basic).


Exception Type Condition
ArgumentException value is not an Int32.


Any instance of Int32, regardless of its value, is considered greater than a null reference (Nothing in Visual Basic). value must be a null reference (Nothing) or an instance of Int32; otherwise, an exception is thrown.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Int32 Structure | Int32 Members | System Namespace | UInt32 | Equals

© 2017 Microsoft