Struct Quantity
Physical quantity.
public record struct Quantity : IComparable<Quantity>, IEquatable<Quantity>
- Implements
- Inherited Members
Constructors
Quantity(double, Unit)
Physical quantity.
public Quantity(double Value, Unit Unit)
Parameters
Quantity(float, Unit)
Creates an instance of the Quantity struct.
public Quantity(float value, Unit unit)
Parameters
Properties
Unit
The unit.
public Unit Unit { readonly get; set; }
Property Value
Value
The value.
public double Value { readonly get; set; }
Property Value
Methods
CompareTo(Quantity)
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 readonly int CompareTo(Quantity other)
Parameters
otherQuantity- An object to compare with this instance.
Returns
- int
- A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value
Meaning
Less than zero
This instance precedes
otherin the sort order. Zero This instance occurs in the same position in the sort order asother. Greater than zero This instance followsotherin the sort order.
Equals(Quantity)
Indicates whether the current object is equal to another object of the same type.
public readonly bool Equals(Quantity other)
Parameters
otherQuantity- An object to compare with this object.
Returns
GetHashCode()
Returns the hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
- A 32-bit signed integer that is the hash code for this instance.
To(Unit)
Converts the current quantity to a quantity with the specified unit.
public readonly Quantity To(Unit unit)
Parameters
unitUnit- The target unit.
Returns
- Quantity
- A new quantity converted to
unit.
Exceptions
- InvalidOperationException
- The target unit has a different dimension from the current quantity's unit.
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
- The fully qualified type name.
Operators
operator >(Quantity, Quantity)
public static bool operator >(Quantity left, Quantity right)
Parameters
Returns
operator >=(Quantity, Quantity)
public static bool operator >=(Quantity left, Quantity right)
Parameters
Returns
operator <(Quantity, Quantity)
public static bool operator <(Quantity left, Quantity right)
Parameters
Returns
operator <=(Quantity, Quantity)
public static bool operator <=(Quantity left, Quantity right)