Size.Implicit(Size to SizeF) 運算子

定義

將指定的 Size 結構轉換成 SizeF 結構。

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

參數

p
Size

要轉換的 Size 結構。

傳回

這個運算子轉換成的 SizeF 結構。

範例

下列程式代碼範例示範 G和 成員的 ColorRB、 和 AImplicit 屬性。

此範例的設計目的是要與 Windows Form 搭配使用。 將程式代碼貼到表單中,並從表單Paint的事件處理方法呼叫 ShowPropertiesOfSlateBlue 方法,並e傳遞為 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));
}

適用於

產品 版本
.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