• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support
Show / Hide Table of Contents

Struct Size

Represents the size of a rectangular region with an ordered pair of integers.

Implements
IEquatable<Size>
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
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)

Initializes a new Size from a 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

true if the sizes are equal; otherwise, false.

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

true if the objects are equal; otherwise, false.

Overrides
ValueType.Equals(object)
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
ValueType.GetHashCode()
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()

Converts this Size to a SizeF.

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
ValueType.ToString()
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)

Explicitly converts a Size to a Point.

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)

Implicitly converts a Size to a SizeF.

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.

Implements

IEquatable<T>
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX