BigInteger.Equals Method (Object)


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

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

public override bool Equals(
	object obj


Type: System.Object

The object to compare.

Return Value

Type: System.Boolean

true if the obj argument is a BigInteger object, and its value is equal to the value of the current BigInteger instance; otherwise, false.

If the obj argument is not a BigInteger value, the method returns false. The method returns true only if obj is a BigInteger instance whose value is equal to the current instance.

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

The following example defines parallel Object and BigInteger arrays. Each element of one array has the same value as the corresponding element of the second array. As the output from the example shows, the instance in the BigInteger array is considered to be equal to the instance in the Object array only if the latter is a BigInteger and their values are equal.

using System;
using System.Numerics;

public class Example
   public static void Main()
      object[] obj = { 0, 10, 100, new BigInteger(1000), -10 };
      BigInteger[] bi = { BigInteger.Zero, new BigInteger(10),
                          new BigInteger(100), new BigInteger(1000),
                          new BigInteger(-10) };
      for (int ctr = 0; ctr < bi.Length; ctr++)
// The example displays the following output:
//       False
//       False
//       False
//       True
//       False

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