Vector.Equals Method

Definition

Compares two vectors for equality.

Overloads

Equals(Vector)

Compares two vectors for equality.

Equals(Vector, Vector)

Compares the two specified vectors for equality.

Equals(Object)

Determines whether the specified Object is a Vector structure and, if it is, whether it has the same X and Y values as this vector.

Remarks

A vector's X and Y properties are described using Double values. Because the value of a Double can lose precision when arithmetic operations are performed on it, a comparison between two Double structures that are logically equal might fail.

Equals(Vector)

Compares two vectors for equality.

C#
public bool Equals(System.Windows.Vector value);

Parameters

value
Vector

The vector to compare with this vector.

Returns

true if value has the same X and Y values as this vector; otherwise, false.

Examples

The following example shows how to use this method to check whether two Vector structures are equal.

C#
private Boolean equalsExample2()
{

    Vector vector1 = new Vector(20, 30);
    Vector vector2 = new Vector(20, 30);
    Boolean areEqual = false;

    // areEqual is True.  Both parameters are Vector structures, 
    // and they are equal.
    if (vector1.Equals(vector2))
    {
        areEqual = true;
    }

    return areEqual;
}

Remarks

A vector's X and Y properties are described using Double values. Because the value of a Double can lose precision when arithmetic operations are performed on it, a comparison between two Vector structures that are logically equal might fail.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Equals(Vector, Vector)

Compares the two specified vectors for equality.

C#
public static bool Equals(System.Windows.Vector vector1, System.Windows.Vector vector2);

Parameters

vector1
Vector

The first vector to compare.

vector2
Vector

The second vector to compare.

Returns

true if the X and Y components of vector1 and vector2 are equal; otherwise, false.

Examples

The following example shows how to use this method to check whether two Vector structures are equal.

C#
private Boolean equalsExample1()
{

    Vector vector1 = new Vector(20, 30);
    Vector vector2 = new Vector(20, 30);
    Boolean areEqual = false;

    // areEqual is True
    if (Vector.Equals(vector1, vector2))
    {
      areEqual = true;
    }

    return areEqual;
}

Remarks

A vector's X and Y properties are described using Double values. Because the value of a Double can lose precision when arithmetic operations are performed on it, a comparison between two Double structures that are logically equal might fail.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Equals(Object)

Determines whether the specified Object is a Vector structure and, if it is, whether it has the same X and Y values as this vector.

C#
public override bool Equals(object o);

Parameters

o
Object

The vector to compare.

Returns

true if o is a Vector and has the same X and Y values as this vector; otherwise, false.

Examples

The following example shows how to use this method to check whether a Vector and an Object are equal.

C#
private Boolean equalsExample2()
{

    Vector vector1 = new Vector(20, 30);
    Vector vector2 = new Vector(20, 30);
    Boolean areEqual = false;

    // areEqual is True.  Both parameters are Vector structures, 
    // and they are equal.
    if (vector1.Equals(vector2))
    {
        areEqual = true;
    }

    return areEqual;
}

Remarks

A vector's X and Y properties are described using Double values. Because the value of a Double can lose precision when arithmetic operations are performed on it, a comparison between two Vector structures that are logically equal might fail.

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10