BigInteger::CompareTo Method (BigInteger)
Compares this instance to a second BigInteger and returns an integer that indicates whether the value of this instance is less than, equal to, or greater than the value of the specified object.
Assembly: System.Numerics (in System.Numerics.dll)
- Type: System.Numerics::BigInteger
The object to compare.
Return ValueType: System::Int32
A signed integer value that indicates the relationship of this instance to other, as shown in the following table.
Less than zero
The current instance is less than other.
The current instance equals other.
Greater than zero
The current instance is greater than other.
The following example illustrates the use of the method to order a list of StarInfo objects. Each StarInfo object provides information about a star's name and its distance from the Earth in miles. StarInfo implements the IComparable<T> interface, which enables StarInfo objects to be sorted by generic collection classes. Its IComparable<T>::CompareTo implementation just wraps a call to .
The following code then instantiates four StarInfo objects and stores them in a generic List<T> object. After the List<T>::Sort method is called, StarInfo objects are displayed in order of their distance from the Earth.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.