This documentation is archived and is not being maintained.

Unit Structure

Represents a length measurement.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

[SerializableAttribute]
[TypeConverterAttribute(typeof(UnitConverter))]
public value class Unit

The Unit type exposes the following members.

  NameDescription
Public methodUnit(Double)Initializes a new instance of the Unit structure with the specified double precision floating point number.
Public methodUnit(Int32)Initializes a new instance of the Unit structure with the specified 32-bit signed integer.
Public methodUnit(String)Initializes a new instance of the Unit structure with the specified length.
Public methodUnit(Double, UnitType)Initializes a new instance of the Unit structure with the specified double precision floating point number and UnitType.
Public methodUnit(String, CultureInfo)Initializes a new instance of the Unit structure with the specified length and System.Globalization::CultureInfo.
Top

  NameDescription
Public propertyIsEmptyGets a value indicating whether the Unit is empty.
Public propertyTypeGets the unit type of the Unit.
Public propertyValueGets the length of the Unit.
Top

  NameDescription
Public methodEqualsCompares this Unit with the specified object. (Overrides ValueType::Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeReturns a hash code for this Unit. (Overrides ValueType::GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodStatic memberParse(String)Converts the specified string to a Unit.
Public methodStatic memberParse(String, CultureInfo)Converts the specified string and System.Globalization::CultureInfo to a Unit.
Public methodStatic memberPercentageCreates a Unit of type Percentage from the specified double-precision floating-point number.
Public methodStatic memberPixelCreates a Unit of type Pixel from the specified 32-bit signed integer.
Public methodStatic memberPointCreates a Unit of type Point from the specified 32-bit signed integer.
Public methodToString()Infrastructure. Converts a Unit to a System::String. (Overrides ValueType::ToString().)
Public methodToString(CultureInfo)Converts a Unit to a string equivalent in the specified culture.
Public methodToString(IFormatProvider)Converts a Unit to a string equivalent using the specified format provider.
Top

  NameDescription
Public operatorStatic memberEqualityCompares two Unit objects to determine whether they are equal.
Public operatorStatic memberImplicit(Int32 to Unit)Implicitly creates a Unit of type Pixel from the specified 32-bit unsigned integer.
Public operatorStatic memberInequalityCompares two Unit objects to determine whether they are not equal.
Top

  NameDescription
Public fieldStatic memberEmptyRepresents an empty Unit. This field is read-only.
Top

The Unit structure represents a length measurement that can be expressed in any HTML-compatible size unit. The UnitType enumeration lists the units of measurement that can be represented. The Unit is used by properties such as BorderWidth and Height to represent the length or width of the property. For example, you can set the BorderWidth property of a Web Server control to a Unit that represents five pixels.

NoteNote

The Unit class can represent values only between -32768 and 32767.

Use the Value property to determine the length of the measurement. The unit of measurement is determined using the Type property. You can convert other data types to a Unit by using the Parse, Percentage, Pixel, and Point methods.

For a list of initial property values for an instance of Unit, see the Unit constructor.

The following code example demonstrates how to use a Style object to change the style properties of multiple controls at once. Each time one of the Style property values changes, each control must call its ApplyStyle method. Note that not all the controls support all the properties demonstrated. If a control does not support a particular property, the appearance of the control will not change when the property value is changed.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: