Unit Structure
Represents a length measurement.
Assembly: System.Web (in System.Web.dll)
The Unit type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | Unit(Double) | Initializes a new instance of the Unit structure with the specified double precision floating point number. |
![]() | Unit(Int32) | Initializes a new instance of the Unit structure with the specified 32-bit signed integer. |
![]() | Unit(String) | Initializes a new instance of the Unit structure with the specified length. |
![]() | Unit(Double, UnitType) | Initializes a new instance of the Unit structure with the specified double precision floating point number and UnitType. |
![]() | Unit(String, CultureInfo) | Initializes a new instance of the Unit structure with the specified length and System.Globalization::CultureInfo. |
| Name | Description | |
|---|---|---|
![]() | Equals | Compares this Unit with the specified object. (Overrides ValueType::Equals(Object).) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Returns a hash code for this Unit. (Overrides ValueType::GetHashCode().) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() ![]() | Parse(String) | Converts the specified string to a Unit. |
![]() ![]() | Parse(String, CultureInfo) | Converts the specified string and System.Globalization::CultureInfo to a Unit. |
![]() ![]() | Percentage | Creates a Unit of type Percentage from the specified double-precision floating-point number. |
![]() ![]() | Pixel | Creates a Unit of type Pixel from the specified 32-bit signed integer. |
![]() ![]() | Point | Creates a Unit of type Point from the specified 32-bit signed integer. |
![]() | ToString() | Infrastructure. Converts a Unit to a System::String. (Overrides ValueType::ToString().) |
![]() | ToString(CultureInfo) | Converts a Unit to a string equivalent in the specified culture. |
![]() | ToString(IFormatProvider) | Converts a Unit to a string equivalent using the specified format provider. |
| Name | Description | |
|---|---|---|
![]() ![]() | Equality | Compares two Unit objects to determine whether they are equal. |
![]() ![]() | Implicit(Int32 to Unit) | Implicitly creates a Unit of type Pixel from the specified 32-bit unsigned integer. |
![]() ![]() | Inequality | Compares two Unit objects to determine whether they are not equal. |
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.
Note |
|---|
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.
| Topic | Location |
|---|---|
| How to: Set Web Server Control Unit Properties | Building ASP .NET Web Applications |
| How to: Set Web Server Control Unit Properties | Building ASP .NET Web Applications |
| How to: Set Web Server Control Unit Properties |
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.
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.






Note