Επεξεργασία

Κοινή χρήση μέσω


Complex.Equality(Complex, Complex) Operator

Definition

Returns a value that indicates whether two complex numbers are equal.

public:
 static bool operator ==(System::Numerics::Complex left, System::Numerics::Complex right);
public:
 static bool operator ==(System::Numerics::Complex left, System::Numerics::Complex right) = System::Numerics::IEqualityOperators<System::Numerics::Complex, System::Numerics::Complex, bool>::op_Equality;
public static bool operator == (System.Numerics.Complex left, System.Numerics.Complex right);
static member ( = ) : System.Numerics.Complex * System.Numerics.Complex -> bool
Public Shared Operator == (left As Complex, right As Complex) As Boolean

Parameters

left
Complex

The first complex number to compare.

right
Complex

The second complex number to compare.

Returns

true if the left and right parameters have the same value; otherwise, false.

Implements

Remarks

The Equality method defines the operation of the equality operator for Complex values. It enables code such as the following:

Complex c1 = new Complex(12.6, 4.3);
Complex c2 = new Complex(11.1, 8.9);
if (c1 == c2)
let c1 = Complex(12.6, 4.3);
let c2 = Complex(11.1, 8.9);
if c1 = c2 then
Dim c1 As New Complex(12.6, 4.3)
Dim c2 As New Complex(11.1, 8.9)
If c1 = c2 Then

Languages that don't support custom operators can call the Equals(Complex) method instead.

Two complex numbers are equal if their real parts are equal and their imaginary parts are equal. The Equality method is equivalent to the following expression:

return this.Real == value.Real && this.Imaginary == value.Imaginary;
this.Real = value.Real && this.Imaginary = value.Imaginary
Return Me.Real = value.Real AndAlso Me.Imaginary = value.Imaginary

Note that, because of differences in precision, two complex numbers that are apparently equivalent can be considered unequal. For more information and a possible workaround, see the Equals(Complex) method.

The equivalent method for this operator is Complex.Equals

Applies to