Size.Subtract(Size, Size) 方法

定义

用另一个 Size 结构的宽度和高度减去一个 Size 结构的宽度和高度。

public:
 static System::Drawing::Size Subtract(System::Drawing::Size sz1, System::Drawing::Size sz2);
public static System.Drawing.Size Subtract (System.Drawing.Size sz1, System.Drawing.Size sz2);
static member Subtract : System.Drawing.Size * System.Drawing.Size -> System.Drawing.Size
Public Shared Function Subtract (sz1 As Size, sz2 As Size) As Size

参数

sz1
Size

减法运算符左侧的 Size 结构。

sz2
Size

减法运算符右侧的 Size 结构。

返回

一个 Size 结构,它是该减法运算的结果。

示例

下面的代码示例演示如何使用 Subtract 方法。 若要运行此示例,请将其粘贴到 Windows 窗体中。 处理窗体的 Paint 事件,并从Paint事件处理方法调用 SubtractSizes 方法,作为 ePaintEventArgs传递。

private void SubtractSizes(PaintEventArgs e)
{
    Size size1 = new Size(100, 100);
    Size size2 = new Size(50, 50);
    e.Graphics.DrawRectangle(Pens.Black, new Rectangle(new Point(10, 10), size1));
    size1 = Size.Subtract(size1, size2);
    e.Graphics.DrawRectangle(Pens.Red, new Rectangle(new Point(10, 10), size1));
}
Private Sub SubtractSizes(ByVal e As PaintEventArgs) 
    Dim size1 As New Size(100, 100)
    Dim size2 As New Size(50, 50)
    e.Graphics.DrawRectangle(Pens.Black, _
        New Rectangle(New Point(10, 10), size1))
    size1 = System.Drawing.Size.Subtract(size1, size2)
    e.Graphics.DrawRectangle(Pens.Red, _
        New Rectangle(New Point(10, 10), size1))

End Sub

适用于

另请参阅