Aracılığıyla paylaş


BigInteger.Equals Method (UInt64)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
<CLSCompliantAttribute(False)> _
Public Function Equals ( _
    other As ULong _
) As Boolean
[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.

Remarks

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

Examples

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

outputBlock.Text &= "Approx. equal distances from Epsilon Indi to:" & vbCrLf
outputBlock.Text += String.Format("   Altair: {0}", _
                  epsilonIndiDistance.Equals(altairDistance)) & vbCrLf
outputBlock.Text += String.Format("   Ursae Majoris 47: {0}", _
                  epsilonIndiDistance.Equals(ursaeMajoris47Distance)) & vbCrLf
outputBlock.Text += String.Format("   TauCeti: {0}", _
                  epsilonIndiDistance.Equals(tauCetiDistance)) & vbCrLf
outputBlock.Text += String.Format("   Procyon 2: {0}", _
                  epsilonIndiDistance.Equals(procyon2Distance)) & vbCrLf
outputBlock.Text += String.Format("   Wolf 424 AB: {0}", _
                  epsilonIndiDistance.Equals(wolf424ABDistance)) & vbCrLf
' 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
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;

outputBlock.Text += "Approx. equal distances from Epsilon Indi to:" + "\n";
outputBlock.Text += String.Format("   Altair: {0}",
                  epsilonIndiDistance.Equals(altairDistance)) + "\n";
outputBlock.Text += String.Format("   Ursae Majoris 47: {0}",
                  epsilonIndiDistance.Equals(ursaeMajoris47Distance)) + "\n";
outputBlock.Text += String.Format("   TauCeti: {0}",
                  epsilonIndiDistance.Equals(tauCetiDistance)) + "\n";
outputBlock.Text += String.Format("   Procyon 2: {0}",
                  epsilonIndiDistance.Equals(procyon2Distance)) + "\n";
outputBlock.Text += String.Format("   Wolf 424 AB: {0}",
                  epsilonIndiDistance.Equals(wolf424ABDistance)) + "\n";
// 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      

Version Information

Silverlight

Supported in: 5, 4

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.