Skip to main content
.NET Framework Class Library
Size..::.Add Method

Adds the width and height of one Size structure to the width and height of another Size structure.

Namespace: System.Drawing
Assembly: System.Drawing (in System.Drawing.dll)
Syntax
Public Shared Function Add ( _
	sz1 As Size, _
	sz2 As Size _
) As Size
public static Size Add(
	Size sz1,
	Size sz2
)
public:
static Size Add(
	Size sz1, 
	Size sz2
)
static member Add : 
        sz1:Size * 
        sz2:Size -> Size 

Parameters

sz1
Type: System.Drawing..::.Size
The first Size structure to add.
sz2
Type: System.Drawing..::.Size
The second Size structure to add.

Return Value

Type: System.Drawing..::.Size
A Size structure that is the result of the addition operation.
Examples

The following code example demonstrates how to use the Add method. To run this example, paste it into a Windows Form. Handle the form’s Paint event and call the AddSizes method from the Paint event-handling method, passing e as PaintEventArgs.


Private Sub AddSizes(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.Add(size1, size2)
    e.Graphics.DrawRectangle(Pens.Red, New Rectangle(New Point(10, 10), size1))

End Sub


private void AddSizes(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.Add(size1, size2);
    e.Graphics.DrawRectangle(Pens.Red, new Rectangle(new Point(10, 10), size1));
}

Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Microsoft is conducting an online survey to understand your opinion of the MSDN Web site. If you choose to participate, the online survey will be presented to you when you leave the MSDN Web site.

Would you like to participate?