This documentation is archived and is not being maintained.

Boolean.CompareTo Method

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

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


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

Return Value

A signed integer that indicates the relative order of this instance and obj.

Return Value Condition
Less than zero This instance is false and obj is true.
Zero This instance and obj are equal (either both are true or both are false).
Greater than zero This instance is true and obj is false.


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


Exception Type Condition
ArgumentException obj is not a Boolean.


obj must be a null reference (Nothing in Visual Basic) or an instance of Boolean; otherwise, an exception is thrown.

This method is implemented to support the IComparable interface.


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

Boolean Structure | Boolean Members | System Namespace | Equals | Object