LengthUnit

ReferencesSince v9.0
[DebuggerDisplay("{DebuggerDisplay, nq}")] public readonly struct LengthUnit : IEquatable<LengthUnit>, IComparable<LengthUnit>
Represents a length unit.

Fields

Centimeters

#
public static readonly LengthUnit Centimeters
1 millimeter = 1.0e-2 meters

Feet

#
public static readonly LengthUnit Feet
1 foot = 0.3048 meters = 12 inches

Inches

#
public static readonly LengthUnit Inches
1 inch = 0.0254 meters = 1/12 foot

Kilometers

#
public static readonly LengthUnit Kilometers
1 kilometer = 1.0e+3 meters

Meters

#
public static readonly LengthUnit Meters
SI meter length unit

Miles

#
public static readonly LengthUnit Miles
1 yard = 1609.344 meters = 5280 feet

Millimeters

#
public static readonly LengthUnit Millimeters
1 millimeter = 1.0e-3 meters

None

#
public static readonly LengthUnit None
No unit

Unset

#
public static readonly LengthUnit Unset
Unset unit

Yards

#
public static readonly LengthUnit Yards
1 yard = 0.9144 meters = 3 feet

Properties

DisplayName

#Since v9.0
[DebuggerBrowsable(DebuggerBrowsableState.Never)] public string DisplayName { get; }
Upper case plural localized unit name.

DisplaySymbol

#Since v9.0
[DebuggerBrowsable(DebuggerBrowsableState.Never)] public string DisplaySymbol { get; }
Lower case singular localized unit symbol.

Name

#Since v9.0
public string Name { get; }
Non localized lower case plural unit name.

Symbol

#Since v9.0
public string Symbol { get; }
Non localized unit symbol string.

Methods

CompareTo

#Since v9.0
public int CompareTo(LengthUnit other)
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)
other (LengthUnit)A LengthUnit to compare with this instance.
A value that indicates the relative order of the objects being compared.

Equals

#Since v9.0
public bool Equals(LengthUnit other)
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)
other (LengthUnit)
true if the current object is equal to the other object otherwise false.

Equals

#
public override bool Equals(object other)
Indicates whether the current object is equal to another object of the same type.
other (object)
true if the current object is equal to the other object otherwise false.
ValueType.Equals

FromCustomUnitSystem

#Since v9.0
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.
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
ArgumentNullExceptionWhen name is null
ArgumentExceptionWhen customUnitSize is not a positive finite number

FromKnownUnitSystem

#Since v9.0
public static LengthUnit FromKnownUnitSystem(UnitSystem knownUnitSystem)
Constructs a LengthUnit from a UnitSystem.
knownUnitSystem (UnitSystem)A known unit system.

GetHashCode

#
public override int GetHashCode()
Returns the hash code for this instance.
A 32-bit integer that is the hash code for this instance.

IsCustom

#Since v9.0
public static bool IsCustom(in LengthUnit unit)
Determines whether the specified value is a custom unit.
unit (in LengthUnit)

IsKnownLengthUnit

#Since v9.0
public static bool IsKnownLengthUnit(UnitSystem unitSystem, out LengthUnit lengthUnit)
Determines whether the provided value is a known unit system.
unitSystem (UnitSystem)
lengthUnit (out LengthUnit)
True when provided lengthUnit value is a valid known UnitSystem, False otherwise.

IsKnownUnitSystem

#Since v9.0
public bool IsKnownUnitSystem(out UnitSystem unitSystem)
Determines whether the instance value is a known unit system.
unitSystem (out UnitSystem)
True when this instance value is a valid known UnitSystem, False otherwise.

IsNone

#Since v9.0
public static bool IsNone(in LengthUnit unit)
Determines whether the specified value is None.
unit (in LengthUnit)

IsUnset

#Since v9.0
public static bool IsUnset(in LengthUnit unit)
Determines whether the specified value is Unset.
unit (in LengthUnit)

Scale

#Since v9.0
public static double Scale(in LengthUnit from, in LengthUnit to)
Computes the scale factor for changing a measurement on different units.
from (in LengthUnit)The units to convert from.
to (in LengthUnit)The units to convert measurements into.
A unit scale factor.

Size

#Since v9.0
public double Size(in LengthUnit unit)
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.
unit (in LengthUnit)Size unit.
The size of this length unit expressed on the specified length unit.

ToUnitSystem

#Since v9.0
public UnitSystem ToUnitSystem(out double metersPerUnit)
Returns a UnitSystem equivalent to this instance and its size expressed on meters.
metersPerUnit (out double)Unit size expressed in meters.
A UnitSystem value.

ToUnitSystem

#Since v9.0
public UnitSystem? ToUnitSystem(out double factor, ISet<UnitSystem> unitSystems)
Returns the most similar UnitSystem to this instance available on unitSystems set.
factor (out double)
unitSystems (ISet<UnitSystem>)
A UnitSystem in the provided set of available unitSystems.

Operators

OperationResultDescription
LengthUnit==LengthUnitboolEquality operator.
LengthUnit>LengthUnitboolGreater than operator.
LengthUnit>=LengthUnitboolGreater than or equal operator.
LengthUnit!=LengthUnitboolInequality operator.
LengthUnit<LengthUnitboolLess than operator.
LengthUnit<=LengthUnitboolLess than or equal operator.