Point.Subtraction(Point, Size) Operator

Definition

Translates a Point by the negative of a given Size.

C#
public static System.Drawing.Point operator -(System.Drawing.Point pt, System.Drawing.Size sz);

Parameters

pt
Point

The Point to translate.

sz
Size

A Size that specifies the pair of numbers to subtract from the coordinates of pt.

Returns

A Point structure that is translated by the negative of a given Size structure.

Examples

The following code example demonstrates how to use the PointConverter and the Subtraction operator. This example is designed to be used with Windows Forms. Paste this code into a form and call the ShowPointConverter method when handling the form's Paint event, passing e as PaintEventArgs.

C#
private void ShowPointConverter(PaintEventArgs e)
{

    // Create the PointConverter.
    System.ComponentModel.TypeConverter converter = 
        System.ComponentModel.TypeDescriptor.GetConverter(typeof(Point));

    Point point1 = (Point) converter.ConvertFromString("200, 200");

    // Use the subtraction operator to get a second point.
    Point point2 = point1 - new Size(190, 190);

    // Draw a line between the two points.
    e.Graphics.DrawLine(Pens.Black, point1, point2);
}

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