Complex.Inequality(Complex, Complex) Operator

Definition

Returns a value that indicates whether two complex numbers are not 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_Inequality;
public static bool operator != (System.Numerics.Complex left, System.Numerics.Complex right);
static member op_Inequality : System.Numerics.Complex * System.Numerics.Complex -> bool
Public Shared Operator != (left As Complex, right As Complex) As Boolean

Parameters

left
Complex

The first value to compare.

right
Complex

The second value to compare.

Returns

true if left and right are not equal; otherwise, false.

Implements

Remarks

The Equality method defines the operation of the inequality operator for complex numbers. 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)
Dim c1 As New Complex(12.6, 4.3)
Dim c2 As New Complex(11.1, 8.9)
If c1 <> c2 Then

Languages that do not support custom operators can test for inequality by calling the Equals(Complex) method and reversing its value.

Note that, because of differences in precision, two complex numbers that are apparently equivalent can be considered unequal. One possible workaround is to implement a comparison method that returns true only if the difference between the two real and imaginary parts of the complex numbers exceeds a certain threshold (such as .01% of the value of the real or imaginary component of one of the complex numbers). For more information, see the Equals(Complex) method.

Applies to

See also