Struct LengthUnit
- Namespace
- xFunc.Maths.Expressions.Units.LengthUnits
- Assembly
- xFunc.Maths.dll
Represents a length unit.
public readonly struct LengthUnit : IEquatable<LengthUnit>
- Implements
- Inherited Members
Fields
AstronomicalUnit
The astronomical unit (au) unit.
public static readonly LengthUnit AstronomicalUnit
Field Value
Centimeter
The centimeter (cm) unit.
public static readonly LengthUnit Centimeter
Field Value
Chain
The chain (ch) unit.
public static readonly LengthUnit Chain
Field Value
Decimeter
The decimeter (dm) unit.
public static readonly LengthUnit Decimeter
Field Value
Foot
The foot (ft) unit.
public static readonly LengthUnit Foot
Field Value
Inch
The inch (in) unit.
public static readonly LengthUnit Inch
Field Value
Kilometer
The kilometer (km) unit.
public static readonly LengthUnit Kilometer
Field Value
LightYear
The light year (ly) unit.
public static readonly LengthUnit LightYear
Field Value
Meter
The meter (m) unit.
public static readonly LengthUnit Meter
Field Value
Micrometer
The micrometer (µm) unit.
public static readonly LengthUnit Micrometer
Field Value
Mile
The mile (mi) unit.
public static readonly LengthUnit Mile
Field Value
Millimeter
The millimeter (mm) unit.
public static readonly LengthUnit Millimeter
Field Value
Nanometer
The nanometer (nm) unit.
public static readonly LengthUnit Nanometer
Field Value
NauticalMile
The nautical mile (nmi) unit.
public static readonly LengthUnit NauticalMile
Field Value
Parsec
The parsec (pc) unit.
public static readonly LengthUnit Parsec
Field Value
Rod
The rod (rd) unit.
public static readonly LengthUnit Rod
Field Value
Yard
The yard (yd) unit.
public static readonly LengthUnit Yard
Field Value
Properties
Factor
Gets a factor of conversion from this unit to base unit.
public double Factor { get; }
Property Value
Names
Gets all available unit names.
public static IEnumerable<string> Names { get; }
Property Value
UnitName
Gets a short name of the unit.
public string UnitName { get; }
Property Value
Units
Gets all available units.
public static IEnumerable<LengthUnit> Units { get; }
Property Value
Methods
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
Equals(LengthUnit)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(LengthUnit other)
Parameters
other
LengthUnitAn object to compare with this object.
Returns
FromName(string, out LengthUnit)
Gets a unit by name.
public static bool FromName(string name, out LengthUnit unit)
Parameters
name
stringThe name of unit.
unit
LengthUnitWhen this method returns, the value associated with the specified name, if the unit is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.
Returns
- bool
true
if length units contain an unit with the specifiedname
; otherwise,false
.
Exceptions
- ArgumentNullException
name
isnull
.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToAreaUnit()
Maps the current length unit to area unit.
public AreaUnit ToAreaUnit()
Returns
- AreaUnit
The area unit.
Exceptions
- InvalidOperationException
Cannot convert the current LengthUnit to an AreaUnit.
- See Also
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(LengthUnit, LengthUnit)
Determines whether two specified instances of LengthValue are equal.
public static bool operator ==(LengthUnit left, LengthUnit right)
Parameters
left
LengthUnitThe first object to compare.
right
LengthUnitThe second object to compare.
Returns
- bool
true
ifleft
is equal toright
; otherwise,false
.
operator !=(LengthUnit, LengthUnit)
Determines whether two specified instances of LengthValue are equal.
public static bool operator !=(LengthUnit left, LengthUnit right)
Parameters
left
LengthUnitThe first object to compare.
right
LengthUnitThe second object to compare.
Returns
- bool
true
ifleft
is equal toright
; otherwise,false
.