LengthUnit

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

Fields

Centimeters

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

Feet

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

Inches

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

Kilometers

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

Meters

#
SI meter length unit
public static readonly LengthUnit Meters

Miles

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

Millimeters

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

None

#
No unit
public static readonly LengthUnit None

Unset

#
Unset unit
public static readonly LengthUnit Unset

Yards

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

Properties

DisplayName

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

DisplaySymbol

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

Name

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

Symbol

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

Methods

CompareTo

#Since v9.0
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.
public int CompareTo(
other
A LengthUnit to compare with this instance.
)
Remarks: Name is ignored on the comparison (Meters and Metres are considered the same)
A value that indicates the relative order of the objects being compared.

Equals

#Since v9.0
Indicates whether the current object is equal to another object of the same type.
public bool Equals()
Remarks: Name is ignored on the comparison (Meters and Metres are considered the same)
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.
public override bool Equals(
other
)
true if the current object is equal to the other object otherwise false.
ValueType.Equals

FromCustomUnitSystem

#Since v9.0
Creates a custom LengthUnit based on its size expressed on a known UnitSystem.
public static LengthUnit FromCustomUnitSystem(
name,
Name of the custom unit
customUnitSize,
Meters per custom unit in case knownUnitSystem is omitted
knownUnitSystem = 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
Constructs a LengthUnit from a UnitSystem.
public static LengthUnit FromKnownUnitSystem(
knownUnitSystem
A known unit system.
)

GetHashCode

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

IsCustom

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

IsKnownLengthUnit

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

IsKnownUnitSystem

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

IsNone

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

IsUnset

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

Scale

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

Size

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

ToUnitSystem

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

ToUnitSystem

#Since v9.0
Returns the most similar UnitSystem to this instance available on unitSystems set.
public UnitSystem? ToUnitSystem(
out double
factor,
unitSystems
)
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.