Export (0) Print
Expand All

BigInteger.Equals Method (UInt64)

Returns a value that indicates whether the current instance and an unsigned 64-bit integer have the same value.

This API is not CLS-compliant. 

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

[CLSCompliantAttribute(false)]
public bool Equals(
	ulong other
)

Parameters

other
Type: System.UInt64

The unsigned 64-bit integer to compare.

Return Value

Type: System.Boolean
true if the current instance and the unsigned 64-bit integer have the same value; otherwise, false.

To determine the relationship between the two objects instead of just testing for equality, call the BigInteger.CompareTo(UInt64) 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 long LIGHT_YEAR = 5878625373183;

BigInteger altairDistance = 17 * LIGHT_YEAR;
BigInteger epsilonIndiDistance = 12 * LIGHT_YEAR;
BigInteger ursaeMajoris47Distance = 46 * LIGHT_YEAR;
long tauCetiDistance = 12 * LIGHT_YEAR;
ulong procyon2Distance = 12 * LIGHT_YEAR;
object wolf424ABDistance = 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      

.NET Framework

Supported in: 4.6, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

Supported in: Windows Phone 8.1

Windows Phone 8.1, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft