[DebuggerDisplay("{DebuggerDisplay, nq}")]
public readonly struct LengthUnit : IEquatable<LengthUnit>, IComparable<LengthUnit>
Represents a length unit.
Fields
Properties
Upper case plural localized unit name.
Lower case singular localized unit symbol.
Methods
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Remarks: Name is ignored on the comparison (Meters and Metres are considered the same)
Parameters:
| other (LengthUnit) | A LengthUnit to compare with this instance. |
Returns: A value that indicates the relative order of the objects being compared.
Indicates whether the current object is equal to another object of the same type.
Remarks: Name is ignored on the comparison (Meters and Metres are considered the same)
Parameters:
| other (LengthUnit) |
Returns: true if the current object is equal to the
other object otherwise false.Equals
#Indicates whether the current object is equal to another object of the same type.
Parameters:
| other (object) |
Returns: true if the current object is equal to the
other object otherwise false.Overrides: ValueType.Equals
public static LengthUnit FromCustomUnitSystem(string name, double customUnitSize, UnitSystem knownUnitSystem = UnitSystem.Meters)
Creates a custom LengthUnit based on its size expressed on a known UnitSystem.
Parameters:
| name (string) | Name of the custom unit |
| customUnitSize (double) | Meters per custom unit in case knownUnitSystem is omitted |
| knownUnitSystem (UnitSystem = UnitSystem.Meters) | A known unit system. Meters when omitted |
Exceptions:
| ArgumentNullException | When name is null |
| ArgumentException | When customUnitSize is not a positive finite number |
Constructs a LengthUnit from a UnitSystem.
Parameters:
| knownUnitSystem (UnitSystem) | A known unit system. |
GetHashCode
#Returns the hash code for this instance.
Returns: A 32-bit integer that is the hash code for this instance.
Overrides: ValueType.GetHashCode
Determines whether the specified value is a custom unit.
Parameters:
| unit (in LengthUnit) |
Determines whether the provided value is a known unit system.
Remarks: Not UnitSystem.Unset nor UnitSystem.CustomUnits
Parameters:
| unitSystem (UnitSystem) | |
| lengthUnit (out LengthUnit) |
Determines whether the instance value is a known unit system.
Remarks: Not UnitSystem.Unset nor UnitSystem.CustomUnits
Parameters:
| unitSystem (out UnitSystem) |
Returns: True when this instance value is a valid known UnitSystem, False otherwise.
Determines whether the specified value is None.
Parameters:
| unit (in LengthUnit) |
Determines whether the specified value is Unset.
Parameters:
| unit (in LengthUnit) |
Computes the scale factor for changing a measurement on different units.
Parameters:
| from (in LengthUnit) | The units to convert from. |
| to (in LengthUnit) | The units to convert measurements into. |
Returns: A unit scale factor.
Returns the size of this unit expressed on a different length unit.
Remarks: Size of None is always 1.0 expressed on any other length unit.
Size of Unset is always NaN expressed on any other length unit.
Size of Unset is always NaN expressed on any other length unit.
Parameters:
| unit (in LengthUnit) | Size unit. |
Returns: The size of this length unit expressed on the specified length
unit.Returns a UnitSystem equivalent to this instance and its size expressed on meters.
Parameters:
| metersPerUnit (out double) | Unit size expressed in meters. |
Returns: A UnitSystem value.
Returns the most similar UnitSystem to this instance available on
unitSystems set.Parameters:
| factor (out double) | |
| unitSystems (ISet<UnitSystem>) |
Operators
| Operation | Result | Description | ||
|---|---|---|---|---|
| LengthUnit | == | LengthUnit | bool | Equality operator. |
| LengthUnit | > | LengthUnit | bool | Greater than operator. |
| LengthUnit | >= | LengthUnit | bool | Greater than or equal operator. |
| LengthUnit | != | LengthUnit | bool | Inequality operator. |
| LengthUnit | < | LengthUnit | bool | Less than operator. |
| LengthUnit | <= | LengthUnit | bool | Less than or equal operator. |