Struct Size
Represents the size of a rectangular region with an ordered pair of integers.
Implements
Inherited Members
Namespace: DRIT.Drawing.Geometry
Assembly: DRIT.Drawing.dll
Syntax
public struct Size : IEquatable<Size>
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Constructors
Size(Point)
Declaration
public Size(Point pt)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | pt | The point to convert to a size. |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Size(int, int)
Initializes a new Size with the specified width and height.
Declaration
public Size(int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | The width. |
| int | height | The height. |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Fields
Empty
Gets an empty Size (0, 0).
Declaration
public static readonly Size Empty
Field Value
| Type | Description |
|---|---|
| Size |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Height
Gets or sets the height.
Declaration
public int Height
Field Value
| Type | Description |
|---|---|
| int |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Width
Gets or sets the width.
Declaration
public int Width
Field Value
| Type | Description |
|---|---|
| int |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Properties
IsEmpty
Gets a value indicating whether this size is empty (0, 0).
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Methods
Add(Size, Size)
Adds two sizes.
Declaration
public static Size Add(Size sz1, Size sz2)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | sz1 | The first size. |
| Size | sz2 | The second size. |
Returns
| Type | Description |
|---|---|
| Size | The resulting size. |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Equals(Size)
Indicates whether this size is equal to another size.
Declaration
public bool Equals(Size other)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | other | The size to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Equals(object?)
Indicates whether this size is equal to another object.
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
GetHashCode()
Returns a hash code for this size.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | The hash code. |
Overrides
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Subtract(Size, Size)
Subtracts the second size from the first.
Declaration
public static Size Subtract(Size sz1, Size sz2)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | sz1 | The size to subtract from. |
| Size | sz2 | The size to subtract. |
Returns
| Type | Description |
|---|---|
| Size | The resulting size. |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
ToSizeF()
Declaration
public SizeF ToSizeF()
Returns
| Type | Description |
|---|---|
| SizeF | A new SizeF with the same dimensions. |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
ToString()
Returns a string representation of this size.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string in the format "{Width=value, Height=value}". |
Overrides
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
Operators
operator +(Size, Size)
Adds two sizes.
Declaration
public static Size operator +(Size sz1, Size sz2)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | sz1 | |
| Size | sz2 |
Returns
| Type | Description |
|---|---|
| Size |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
operator ==(Size, Size)
Compares two sizes for equality.
Declaration
public static bool operator ==(Size left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | |
| Size | right |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
explicit operator Point(Size)
Declaration
public static explicit operator Point(Size sz)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | sz |
Returns
| Type | Description |
|---|---|
| Point |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
implicit operator SizeF(Size)
Declaration
public static implicit operator SizeF(Size sz)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | sz |
Returns
| Type | Description |
|---|---|
| SizeF |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
operator !=(Size, Size)
Compares two sizes for inequality.
Declaration
public static bool operator !=(Size left, Size right)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | left | |
| Size | right |
Returns
| Type | Description |
|---|---|
| bool |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.
operator -(Size, Size)
Subtracts two sizes.
Declaration
public static Size operator -(Size sz1, Size sz2)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | sz1 | |
| Size | sz2 |
Returns
| Type | Description |
|---|---|
| Size |
Remarks
A Size represents the width and height of a rectangle. Width and Height are public fields for performance reasons, matching the System.Drawing API.