Length
Leave feedback
On this page
Represents a CSS length value in any supportable unit, including percentage and unitless type. Values may be integer or float, negative, zero and positive. Immutable structure.
public struct Length : ICloneable, ICssDataType, IEquatable<Length>
| Name | Description |
|---|---|
| FloatValue { get; } | Returns a float numeric value of the Length instance. Never throws an exception - converts Integer value to Float if necessary. |
| IntegerValue { get; } | Returns an integer numeric value of this Length instance, if it is internally stored as an integer, or throws an exception, if it was originally stored as a float number. |
| IsAbsolute { get; } | Gets if the length is given in absolute units. Such a length may be converted to pixels. |
| IsDefault { get; } | Indicates whether this Length instance has a default value — unitless zero. Same as IsUnitlessZero property. |
| IsFloat { get; } | Indicates whether the numeric value of this Length instance was originally specified and stored as a float (FP32) number |
| IsInteger { get; } | Indicates whether the numeric value of this Length instance was originally specified and stored as an integer (INT32) number |
| IsNegative { get; } | Determines whether the numeric value of this length is a negative number |
| IsPositive { get; } | Determines whether the numeric value of this length is a positive number |
| IsRelative { get; } | Gets if the length is given in relative units. Such a length cannot be converted to pixels. |
| IsUnitlessNonZero { get; } | The value has unitless type, but is not a zero - positive or negative number |
| IsUnitlessZero { get; } | Determines whether this instance is a unitless zero or not. Unitless zero is default value of this type. Same as IsDefault property. |
| IsZero { get; } | Determines whether the numeric value of this length is a zero number |
| UnitType { get; } | Returns a unit type of this Length instance. |
| Name | Description |
|---|---|
| static FromValueWithUnit(double, Unit) | Creates and returns an instance of Length type by specified double number and unit |
| static FromValueWithUnit(float, Unit) | Creates and returns an instance of Length type by specified float number and unit |
| static FromValueWithUnit(int, Unit) | Creates and returns an instance of Length type by specified integer number and unit |
| static Parse(string) | Parses and returns specified string as a Length value, including its numeric value and unit name, or throws an exception on failure |
| Clone() | Returns a full copy of this Length instance |
| Equals(Length) | Defines whether this value is equal to the other specified length |
| override Equals(object) | Determines whether this length is equal to specified object |
| override GetHashCode() | Calculates and returns a hash-code of this Length instance by combining hash-codes of the value and unit type |
| SerializeDefault() | Returns a string representation of this length in its original native form (as it is stored), without converting length value to some other unit type |
| To(Unit) | Converts the length to the given unit, if possible. If the current or given unit is relative, then an exception will be thrown. |
| ToPixel() | Converts the length to a number of pixels, if possible. If the current unit is relative, then an exception will be thrown. |
| ToStringSpecified(Unit) | Returns a string representation of this length in specified unit type. Numeric value will be converted in corresponding to unit type change. |
| static GetUnitFromName(string) | Tries to parse specified unit name and return corresponding value of a Unit enum. Returns Unit.Unitless if cannot find appropriate unit. |
| static TryParse(string, out Length) | Tries to parse a specified string as a Length value, including its numeric value and unit name |
| operator == | Checks the equality of the two given lengths. |
| operator != | Checks the inequality of the two given lengths. |
| operator * | Multiplicates the given Length onto the given factor |
| Name | Description |
|---|---|
| static readonly FiftyPercents | 50% |
| static readonly OneHundredPercents | 100% |
| static readonly UnitlessZero | Unitless integer zero - default value, the same as default parameterless constructor |
| static readonly ZeroPercents | 0% |
| Name | Description |
|---|---|
| enum Unit | All supported length units |
This type covers the next CSS data types: https://developer.mozilla.org/en-US/docs/Web/CSS/length https://developer.mozilla.org/en-US/docs/Web/CSS/percentage
- interface ICssDataType
- namespace GroupDocs.Editor.HtmlCss.Css.DataTypes
- assembly GroupDocs.Editor
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.