Point.Equality(Point, Point) 运算符

定义

比较两个 Point 结构是否相等。

public:
 static bool operator ==(System::Windows::Point point1, System::Windows::Point point2);
public static bool operator == (System.Windows.Point point1, System.Windows.Point point2);
static member ( = ) : System.Windows.Point * System.Windows.Point -> bool
Public Shared Operator == (point1 As Point, point2 As Point) As Boolean

参数

point1
Point

要比较的第一个 Point 结构。

point2
Point

要比较的第二个 Point 结构。

返回

Boolean

如果两个点(即 point1point2)的 XY 坐标都相等,则为 true;否则为 false

示例

以下示例演示如何使用重载的 (==) 运算符检查两 Point 个结构是否相等。

private Boolean overloadedEqualityOperatorExample()
{
    Point point1 = new Point(10, 5);
    Point point2 = new Point(15, 40);

    // Check if two Points are equal using the overloaded equality operator.
    // areEqual is False.
    Boolean areEqual = (point1 == point2);

    return areEqual;
}
Private Function overloadedEqualityOperatorExample() As Boolean
    Dim point1 As New Point(10, 5)
    Dim point2 As New Point(15, 40)

    ' Check if two Points are equal using the overloaded equality operator.
    ' areEqual is False.
    Dim areEqual As Boolean = (point1 = point2)

    Return areEqual

End Function

注解

点的坐标是使用 Double 值描述的。 由于对它们执行算术运算时的值 Double 可能会丢失精度,因此在逻辑上相等的两 Point 个值之间的比较可能会失败。

适用于

另请参阅