Size.Equality(Size, Size) Operatore

Definizione

Verifica se due strutture Size sono uguali.

C#
public static bool operator == (System.Drawing.Size sz1, System.Drawing.Size sz2);

Parametri

sz1
Size

Struttura Size a sinistra dell'operatore di uguaglianza.

sz2
Size

Struttura Size a destra dell'operatore di uguaglianza.

Restituisce

truese sz1 e sz2 hanno la stessa altezza e larghezza; in caso contrario false.

Esempio

Nell'esempio di codice seguente vengono creati punti e dimensioni usando diversi operatori di overload definiti per questi tipi. Illustra anche come usare la SystemPens classe.

Questo esempio è progettato per essere usato con Windows Forms. Create un modulo contenente un Button oggetto denominato subtractButton. Incollare il codice nel modulo e chiamare il CreatePointsAndSizes metodo dal metodo di gestione degli eventi del Paint modulo, passando e come PaintEventArgs.

C#
private void CreatePointsAndSizes(PaintEventArgs e)
{

    // Create the starting point.
    Point startPoint = new Point(subtractButton.Size);

    // Use the addition operator to get the end point.
    Point endPoint = startPoint + new Size(140, 150);

    // Draw a line between the points.
    e.Graphics.DrawLine(SystemPens.Highlight, startPoint, endPoint);

    // Convert the starting point to a size and compare it to the
    // subtractButton size.  
    Size buttonSize = (Size)startPoint;
    if (buttonSize == subtractButton.Size)

        // If the sizes are equal, tell the user.
    {
        e.Graphics.DrawString("The sizes are equal.", 
            new Font(this.Font, FontStyle.Italic), 
            Brushes.Indigo, 10.0F, 65.0F);
    }
}

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