PointF.Equality(PointF, PointF) Operator

Definition

Compares two PointF structures. The result specifies whether the values of the X and Y properties of the two PointF structures are equal.

C#
public static bool operator ==(System.Drawing.PointF left, System.Drawing.PointF right);

Parameters

left
PointF

A PointF to compare.

right
PointF

A PointF to compare.

Returns

true if the X and Y values of the left and right PointF structures are equal; otherwise, false.

Examples

The following code example demonstrates how to use the Equality operator. To run this example, paste the following code into a Windows Form. Handle the form's Paint event and call opAdditionExample, passing e as PaintEventArgs.

C#
private void OpAdditionExample(PaintEventArgs e)
{
    PointF point1 = new PointF(120.5F, 120F);
    SizeF size1 = new SizeF(120.5F, 30.5F);
    RectangleF rect1 = new RectangleF(point1, size1);
    if (new PointF(rect1.Right, rect1.Bottom) == point1 + size1)
        e.Graphics.DrawString("They are equal", this.Font, Brushes.Black, rect1);
    else
        e.Graphics.DrawString("They are not equal", this.Font, Brushes.Red, rect1);
}

Applies to

Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 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
.NET Standard 2.0, 2.1