Point.Equality(Point, Point) Operator

Definition

Compares two Point structures for equality.

C#
public static bool operator ==(System.Windows.Point point1, System.Windows.Point point2);

Parameters

point1
Point

The first Point structure to compare.

point2
Point

The second Point structure to compare.

Returns

true if both the X and Y coordinates of point1 and point2 are equal; otherwise, false.

Examples

The following example shows how to check if two Point structures are equal using the overloaded (==) operator.

C#
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;
}

Remarks

A point's coordinates are described using Double values. Because the value of Double can lose precision when arithmetic operations are performed on them, a comparison between two Point values that are logically equal might fail.

Applies to

Produkt Verzie
.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

See also