Point.Subtraction(Point, Size) Operatore

Definizione

Converte un elemento Point in base al valore negativo di un elemento Size.

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

Parametri

pt
Point

Point da convertire.

sz
Size

Oggetto Size che specifica la coppia di numeri da sottrarre alle coordinate di pt.

Restituisce

Struttura Point traslata in base al valore negativo di una determinata struttura Size.

Esempio

Nell'esempio di codice seguente viene illustrato come usare e PointConverter l'operatore Subtraction . Questo esempio è progettato per essere usato con Windows Forms. Incollare questo codice in una maschera e chiamare il ShowPointConverter metodo quando si gestisce l'evento del Paint modulo, passando e come 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);
}

Si applica a

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