Home

.NET Structures: The Size

 

Description

To represent the size of something, the System.Drawing namespace defines the Size structure that is equipped with two main properties. There are four characteristics that define a Size value: its location and its dimensions. A Size value must have a starting point (X, Y) just as the Point object was illustrated earlier. The Width is the distance from the left to the right borders of a Size value. The Height property represents the distance from the top to the bottom borders of a Size value:

Size Representation

 

Based on this, to create a Size object, if you know only its location (X and Y), you can use the following constructor:

Public Sub New (pt As Point)

After declaring a variable with this constructor, you can access its Width and Height properties to complete the definition of the Size object. If you already have the location of a Size object by other means, you may not be interested in (re)defining its location. In this case, you may only want to specify the dimensions of the variable. To do this, you can use the following constructor:

Public Sub New(width As Integer, height As Integer)

Besides Size, the System.Drawing namespace also provides the SizeF structure. It uses the same properties as Size except that its members float values.

 

Home Copyright © 2008-2012 FunctionX Home