Class Unit
Unit.
public record Unit : IEquatable<Unit>
- Inheritance
-
Unit
- Implements
- Derived
- Inherited Members
Remarks
Scale define the mapping to the coherent SI unit of the dimension. Given the value in the current unit x and the scale k, the value in the coherent unit y = k * x.Constructors
Unit(Dimension, double)
Unit.
public Unit(Dimension Dimension, double Scale = 1)
Parameters
Remarks
Scale define the mapping to the coherent SI unit of the dimension. Given the value in the current unit x and the scale k, the value in the coherent unit y = k * x.Properties
Dimension
The dimension.
public Dimension Dimension { get; init; }
Property Value
Scale
The scale.
public double Scale { get; init; }
Property Value
Methods
Divide(Unit, Unit)
Returns the division of a unit divided by another.
public static Unit Divide(Unit left, Unit right)
Parameters
Returns
- Unit
- The division of
leftdivided byright.
From(double, Unit)
Converts the specified value in the specified unit to a value in the current unit.
public double From(double value, Unit unit)
Parameters
Returns
- double
- A value in the current unit.
Exceptions
- ArgumentNullException
unitis null.
FromCoherent(double)
Converts the specified value in the coherent unit to a value in the current unit.
public virtual double FromCoherent(double value)
Parameters
valuedouble- The value in the coherent unit.
Returns
- double
- A value in the current unit.
Multiply(Unit, Unit)
Returns the multiplication of two units.
public static Unit Multiply(Unit left, Unit right)
Parameters
Returns
- Unit
- The multiplication of the two units.
To(double, Unit)
Converts the specified value in the current unit to a value in the specified unit.
public double To(double value, Unit unit)
Parameters
Returns
- double
- A value in
unit.
Exceptions
- ArgumentNullException
unitis null.
ToCoherent(double)
Converts the specified value in the current unit to a value in the corresponding coherent unit.
public virtual double ToCoherent(double value)
Parameters
valuedouble- The value in the current unit.
Returns
- double
- A value in the corresponding coherent unit.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
- A string that represents the current object.
WithPrefix(double)
Creates a unit based on the current unit modified by the specified prefix.
public Unit WithPrefix(double prefix)
Parameters
prefixdouble- The prefix.
Returns
- Unit
- The new unit.
Operators
operator /(Unit, Unit)
Returns the division of a unit divided by another.
public static Unit operator /(Unit left, Unit right)
Parameters
Returns
- Unit
- The division of
leftdivided byright.
operator *(Unit, Unit)
Returns the multiplication of two units.
public static Unit operator *(Unit left, Unit right)
Parameters
Returns
- Unit
- The multiplication of the two units.