Point.Equality(Point, Point) 运算符
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
比较两个 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
和 point2
)的 X 和 Y 坐标都相等,则为 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 个值之间的比较可能会失败。