C# Complex Equals(Object)
Description
Complex Equals(Object)
Returns a value that indicates
whether the current instance and a specified object have the same value.
Syntax
Complex.Equals(Object)
has the following syntax.
public override bool Equals(
Object obj
)
Parameters
Complex.Equals(Object)
has the following parameters.
obj
- The object to compare.
Returns
Complex.Equals(Object)
method returns true if the obj parameter is a Complex object or a type capable of implicit
conversion to a Complex object, and its value is equal to the current Complex
object; otherwise, false.
Example
/* w ww. ja v a 2s.co m*/
using System;
using System.Numerics;
public class Example
{
public static void Main()
{
float n1 = 1.430718e-12f;
Complex c1 = new Complex(1.430718e-12, 0);
Console.WriteLine("{0} = {1}: {2}", c1, n1, c1.Equals(n1));
n1 = 1.430718e-12f;
c1 = new Complex(1.430718e-12, 0);
double difference = .0001;
bool result = (Math.Abs(c1.Real - n1) <= c1.Real * difference) &
c1.Imaginary == 0;
Console.WriteLine("{0} = {1}: {2}", c1, n1, result);
double d1 = 16.33;
c1 = new System.Numerics.Complex(16.33, 0);
Console.WriteLine(c1.Equals(d1));
}
}
The code above generates the following result.