Size.Implicit(Size to SizeF) Operator

Definicja

Konwertuje określoną Size strukturę na SizeF strukturę.

C#
public static implicit operator System.Drawing.SizeF (System.Drawing.Size p);

Parametry

p
Size

Struktura Size do konwersji.

Zwraca

Struktura SizeF , na którą konwertuje ten operator.

Przykłady

W poniższym przykładzie kodu pokazano Gwłaściwości , B, Ri A elementu Color członkowskiego i Implicit .

Ten przykład jest przeznaczony do użycia z formularzem systemu Windows. Wklej kod do formularza i wywołaj ShowPropertiesOfSlateBlue metodę z metody obsługi zdarzeń formularza Paint , przekazując e jako PaintEventArgs.

C#
private void ShowPropertiesOfSlateBlue(PaintEventArgs e)
{
    Color slateBlue = Color.FromName("SlateBlue");
    byte g = slateBlue.G;
    byte b = slateBlue.B;
    byte r = slateBlue.R;
    byte a = slateBlue.A;
    string text = String.Format("Slate Blue has these ARGB values: Alpha:{0}, " +
        "red:{1}, green: {2}, blue {3}", new object[]{a, r, g, b});
    e.Graphics.DrawString(text, 
        new Font(this.Font, FontStyle.Italic), 
        new SolidBrush(slateBlue), 
        new RectangleF(new PointF(0.0F, 0.0F), this.Size));
}

Dotyczy

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