In This Article

Padding Struct

Specifies a set of values for each side of a rectangle.

[TypeConverter(typeof(PaddingConverter))]
public struct Padding : IEquatable<Padding>
Implements:
IEquatable<Padding>

Constructors

Padding(Sides, int)

Initializes an instance of the structure.

public Padding(Sides sides, int value)
Parameter Type Description
sides Sides

The sides whose value will be initialized to the given value.

value int

The value to set for the given sides.

Padding(int)

Initializes an instance of the structure.

public Padding(int allSides)
Parameter Type Description
allSides int

The value to assign to all sides.

Padding(int, int, int, int)

Initializes an instance of the structure.

public Padding(int left, int top, int right, int bottom)
Parameter Type Description
left int

The left value to set.

top int

The top value to set.

right int

The right value to set.

bottom int

The bottom value to set.

Properties

All

The value of all sides.

public int All { readonly get; set; }

Property Value

int:

Returns 0 if all sides are not equal.

AllSidesEqual

Indicates whether all sides have the same value.

[Browsable(false)]
public readonly bool AllSidesEqual { get; }

Property Value

bool:

true if all sides have the same value; otherwise, false.

Bottom

The bottom value.

public int Bottom { readonly get; set; }

Property Value

int

Empty

An empty Padding object.

public static Padding Empty { get; }

Property Value

Padding

Horizontal

The combined padding for the right and left values.

[Browsable(false)]
public readonly int Horizontal { get; }

Property Value

int

IsEmpty

Indicates whether the padding is set.

[Browsable(false)]
public readonly bool IsEmpty { get; }

Property Value

bool:

true if any member of the padding is set; otherwise, false.

Left

The left value.

public int Left { readonly get; set; }

Property Value

int

Right

The right value.

public int Right { readonly get; set; }

Property Value

int

Top

The top value.

public int Top { readonly get; set; }

Property Value

int

Vertical

The combined padding for the top and bottom values.

[Browsable(false)]
public readonly int Vertical { get; }

Property Value

int

Zero

A Padding object with all sides equal to zero.

public static Padding Zero { get; }

Property Value

Padding

Methods

Equals(Padding)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(Padding other)
Parameter Type Description
other Padding

An object to compare with this object.

Returns

bool:

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)
Parameter Type Description
obj object

The object to compare with the current instance.

Returns

bool:

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int:

A 32-bit signed integer that is the hash code for this instance.

Operators

operator ==(Padding, Padding)

Compares two Padding objects. The result specifies whether the property values of the two Padding objects are equal.

public static bool operator ==(Padding left, Padding right)
Parameter Type Description
left Padding

A Padding to compare.

right Padding

A Padding to compare.

Returns

bool:

true if the property values of left and right are equal; otherwise, false.

operator !=(Padding, Padding)

Compares two Padding objects. The result specifies whether the property values of the two Padding objects are unequal.

public static bool operator !=(Padding left, Padding right)
Parameter Type Description
left Padding

A Padding to compare.

right Padding

A Padding to compare.

Returns

bool:

true if the property values of left and right are unequal; otherwise, false.

Inherited Members

Extension Methods