Show / Hide Table of Contents

Struct Size

Describes the width and height of an object.

Implements
System.IFormattable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: System.Windows
Assembly: OpenSilver.dll
Syntax
public struct Size : IFormattable

Constructors

| Improve this Doc View Source

Size(Double, Double)

Initializes a new instance of the Size structure and assigns it an initial width and height.

Declaration
public Size(double width, double height)
Parameters
Type Name Description
System.Double width

The initial width of the instance of Size.

System.Double height

The initial height of the instance of Size.

Exceptions
Type Condition
System.ArgumentException

width or height are less than 0.

Properties

| Improve this Doc View Source

Empty

Gets a value that represents a static empty Size.

Declaration
public static readonly Size Empty { get; }
Property Value
Type Description
Size

An empty instance of Size.

| Improve this Doc View Source

Height

Gets or sets the height of this instance of Size.

Declaration
public double Height { get; set; }
Property Value
Type Description
System.Double

The Height of this instance of Size, in pixels. The default is 0. The value cannot be negative.

Exceptions
Type Condition
System.ArgumentException

Specified a value less than 0.

| Improve this Doc View Source

IsEmpty

Gets a value that indicates whether this instance of Size is Empty.

Declaration
public readonly bool IsEmpty { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Width

Gets or sets the width of this instance of Size.

Declaration
public double Width { get; set; }
Property Value
Type Description
System.Double

The Width of this instance of Size, in pixels. The default value is 0. The value cannot be negative.

Exceptions
Type Condition
System.ArgumentException

Specified a value less than 0.

Methods

| Improve this Doc View Source

Equals(Object)

Compares an object to an instance of Size for equality.

Declaration
public override bool Equals(object o)
Parameters
Type Name Description
System.Object o

The object to compare.

Returns
Type Description
System.Boolean

true if the sizes are equal; otherwise, false.

Overrides
System.ValueType.Equals(System.Object)
| Improve this Doc View Source

Equals(Size)

Compares a value to an instance of Size for equality.

Declaration
public bool Equals(Size value)
Parameters
Type Name Description
Size value

The size to compare to this current instance of Size.

Returns
Type Description
System.Boolean

true if the instances of Size are equal; otherwise, false.

| Improve this Doc View Source

Equals(Size, Size)

Compares two instances of Size for equality.

Declaration
public static bool Equals(Size size1, Size size2)
Parameters
Type Name Description
Size size1

The first instance of Size to compare.

Size size2

The second instance of Size to compare.

Returns
Type Description
System.Boolean

true if the instances of Size are equal; otherwise, false.

| Improve this Doc View Source

GetHashCode()

Gets the hash code for this instance of Size.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

The hash code for this instance of Size.

Overrides
System.ValueType.GetHashCode()
| Improve this Doc View Source

Parse(String)

Returns an instance of Size from a converted System.String.

Declaration
public static Size Parse(string source)
Parameters
Type Name Description
System.String source

A System.String value to parse to a Size value.

Returns
Type Description
Size

An instance of Size.

| Improve this Doc View Source

ToString()

Returns a string representation of this Size.

Declaration
public override string ToString()
Returns
Type Description
System.String

A string representation of this Size.

Overrides
System.ValueType.ToString()
| Improve this Doc View Source

ToString(IFormatProvider)

Returns a System.String that represents this instance of Size.

Declaration
public string ToString(IFormatProvider provider)
Parameters
Type Name Description
System.IFormatProvider provider

An object that provides a way to control formatting.

Returns
Type Description
System.String

A System.String that represents this Size object.

Operators

| Improve this Doc View Source

Equality(Size, Size)

Compares two instances of Size for equality.

Declaration
public static bool operator ==(Size size1, Size size2)
Parameters
Type Name Description
Size size1

The first instance of Size to compare.

Size size2

The second instance of Size to compare.

Returns
Type Description
System.Boolean

true if the two instances of Size are equal; otherwise false.

| Improve this Doc View Source

Explicit(Size to Point)

Explicitly converts an instance of Size to an instance of Point.

Declaration
public static explicit operator Point(Size size)
Parameters
Type Name Description
Size size

The Size value to be converted.

Returns
Type Description
Point

A Point equal in value to this instance of Size.

| Improve this Doc View Source

Explicit(Size to Vector)

Explicitly converts an instance of Size to an instance of Vector.

Declaration
public static explicit operator Vector(Size size)
Parameters
Type Name Description
Size size

The Size value to be converted.

Returns
Type Description
Vector

A Vector equal in value to this instance of Size.

| Improve this Doc View Source

Inequality(Size, Size)

Compares two instances of Size for inequality.

Declaration
public static bool operator !=(Size size1, Size size2)
Parameters
Type Name Description
Size size1

The first instance of Size to compare.

Size size2

The second instance of Size to compare.

Returns
Type Description
System.Boolean

true if the instances of Size are not equal; otherwise false.

Explicit Interface Implementations

| Improve this Doc View Source

IFormattable.ToString(String, IFormatProvider)

Creates a string representation of this object based on the format string and IFormatProvider passed in. If the provider is null, the CurrentCulture is used. See the documentation for IFormattable for more information.

Declaration
string IFormattable.ToString(string format, IFormatProvider provider)
Parameters
Type Name Description
System.String format
System.IFormatProvider provider
Returns
Type Description
System.String

A string representation of this object.

Implements

System.IFormattable
  • Improve this Doc
  • View Source