Vector.Equals 方法

定义

比较两个向量是否相等。Compares two vectors for equality.

重载

Equals(Vector)

比较两个向量是否相等。Compares two vectors for equality.

Equals(Vector, Vector)

比较两个指定向量是否相等。Compares the two specified vectors for equality.

Equals(Object)

确定指定的 Object 是不是 Vector 结构,如果是,则确定其是否与此向量具有相同的 XY 值。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.

注解

使用Y XDouble描述矢量的和属性。A vector's X and Y properties are described using Double values. 因为在执行算术运算Double时, 的值可能会丢失精度, 因此, 逻辑上相等的Double两个结构之间的比较可能会失败。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.

public:
 bool Equals(System::Windows::Vector value);
public bool Equals (System.Windows.Vector value);
override this.Equals : System.Windows.Vector -> bool
Public Function Equals (value As Vector) As Boolean

参数

value
Vector

要与此向量比较的向量。The vector to compare with this vector.

返回

如果 value 具有与此向量相同的 XY 值,则为 true;否则为 falsetrue if value has the same X and Y values as this vector; otherwise, false.

示例

下面的示例演示如何使用此方法检查两个Vector结构是否相等。The following example shows how to use this method to check whether two Vector structures are equal.

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;

}

注解

使用Y XDouble描述矢量的和属性。A vector's X and Y properties are described using Double values. 因为在执行算术运算Double时, 的值可能会丢失精度, 因此, 逻辑上相等的Vector两个结构之间的比较可能会失败。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.

另请参阅

Equals(Vector, Vector)

比较两个指定向量是否相等。Compares the two specified vectors for equality.

public:
 static bool Equals(System::Windows::Vector vector1, System::Windows::Vector vector2);
public static bool Equals (System.Windows.Vector vector1, System.Windows.Vector vector2);
static member Equals : System.Windows.Vector * System.Windows.Vector -> bool
Public Shared Function Equals (vector1 As Vector, vector2 As Vector) As Boolean

参数

vector1
Vector

要比较的第一个向量。The first vector to compare.

vector2
Vector

要比较的第二个向量。The second vector to compare.

返回

如果 vector1vector2XY 分量相等,则为 true;否则为 falsetrue if t he X and Y components of vector1 and vector2 are equal; otherwise, false.

示例

下面的示例演示如何使用此方法检查两个Vector结构是否相等。The following example shows how to use this method to check whether two Vector structures are equal.

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;

}

注解

使用Y XDouble描述矢量的和属性。A vector's X and Y properties are described using Double values. 因为在执行算术运算Double时, 的值可能会丢失精度, 因此, 逻辑上相等的Double两个结构之间的比较可能会失败。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(Object)

确定指定的 Object 是不是 Vector 结构,如果是,则确定其是否与此向量具有相同的 XY 值。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.

public:
 override bool Equals(System::Object ^ o);
public override bool Equals (object o);
override this.Equals : obj -> bool
Public Overrides Function Equals (o As Object) As Boolean

参数

o
Object

要比较的向量。The vector to compare.

返回

如果 oVector 并具有与此向量相同的 XY 值,则为 true;否则为 falsetrue if o is a Vector and has the same X and Y values as this vector; otherwise, false.

示例

下面的示例演示如何使用此方法检查Vector Object和是否相等。The following example shows how to use this method to check whether a Vector and an Object are equal.

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;

}

注解

使用Y XDouble描述矢量的和属性。A vector's X and Y properties are described using Double values. 因为在执行算术运算Double时, 的值可能会丢失精度, 因此, 逻辑上相等的Vector两个结构之间的比较可能会失败。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.

另请参阅

适用于