BigInteger.Equals Method (BigInteger)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Returns a value that indicates whether the current instance and a specified BigInteger object have the same value.

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

Public Function Equals (
	other As BigInteger
) As Boolean

Parameters

other
Type: System.Numerics.BigInteger

The object to compare.

Return Value

Type: System.Boolean

true if this BigInteger object and other have the same value; otherwise, false.

This method implements the IEquatable(Of T) interface and performs slightly better than Equals(Object) because it does not have to convert the other parameter to a BigInteger object.

To determine the relationship between the two BigInteger objects instead of just testing for equality, call the BigInteger.CompareTo(BigInteger) method.

The following example compares the approximate distance of several stars from Earth with the distance of Epsilon Indi from Earth to determine whether they are equal. The example uses each overload of the Equals method to test for equality.

Const LIGHT_YEAR As Long = 5878625373183

Dim altairDistance As BigInteger = 17 * LIGHT_YEAR
Dim epsilonIndiDistance As BigInteger = 12 * LIGHT_YEAR
Dim ursaeMajoris47Distance As BigInteger = 46 * LIGHT_YEAR
Dim tauCetiDistance As BigInteger = 12 * LIGHT_YEAR
Dim procyon2Distance As Long = 12 * LIGHT_YEAR
Dim wolf424ABDistance As Object = 14 * LIGHT_YEAR

Console.WriteLine("Approx. equal distances from Epsilon Indi to:")
Console.WriteLine("   Altair: {0}", _
                  epsilonIndiDistance.Equals(altairDistance))
Console.WriteLine("   Ursae Majoris 47: {0}", _
                  epsilonIndiDistance.Equals(ursaeMajoris47Distance))
Console.WriteLine("   TauCeti: {0}", _
                  epsilonIndiDistance.Equals(tauCetiDistance))
Console.WriteLine("   Procyon 2: {0}", _
                  epsilonIndiDistance.Equals(procyon2Distance))
Console.WriteLine("   Wolf 424 AB: {0}", _
                  epsilonIndiDistance.Equals(wolf424ABDistance))
' The example displays the following output:
'    Approx. equal distances from Epsilon Indi to:
'       Altair: False
'       Ursae Majoris 47: False
'       TauCeti: True
'       Procyon 2: True
'       Wolf 424 AB: False

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: