Windows apps
Collapse the table of content
Expand the table of content
Information
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.

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.

Namespace:   System.Numerics
Assembly:  System.Numerics (in System.Numerics.dll)

public:
virtual int CompareTo(
	BigInteger other
) sealed

Parameters

other
Type: System.Numerics::BigInteger

The object to compare.

Return Value

Type: System::Int32

A signed integer value that indicates the relationship of this instance to other, as shown in the following table.

Return value

Description

Less than zero

The current instance is less than other.

Zero

The current instance equals other.

Greater than zero

The current instance is greater than other.

This overload of the CompareTo method implements the IComparable<T>::CompareTo method. It is used by generic collection objects to order the items in the collection.

The following example illustrates the use of the CompareTo(BigInteger) 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 CompareTo(BigInteger).

No code example is currently available or this language may not be supported.

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.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 4.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2017 Microsoft