Struct MassUnit
- Namespace
- xFunc.Maths.Expressions.Units.MassUnits
- Assembly
- xFunc.Maths.dll
Represents a mass unit.
public readonly struct MassUnit : IEquatable<MassUnit>
- Implements
- Inherited Members
Fields
Gram
The gram (g) unit.
public static readonly MassUnit Gram
Field Value
Kilogram
The kilogram (kg) unit.
public static readonly MassUnit Kilogram
Field Value
Milligram
The milligram (mg) unit.
public static readonly MassUnit Milligram
Field Value
Ounce
The ounce (oz) unit.
public static readonly MassUnit Ounce
Field Value
Pound
The pound (lb) unit.
public static readonly MassUnit Pound
Field Value
Tonne
The tonne (t) unit.
public static readonly MassUnit Tonne
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<MassUnit> 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(MassUnit)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(MassUnit other)
Parameters
other
MassUnitAn object to compare with this object.
Returns
FromName(string, out MassUnit)
Gets a unit by name.
public static bool FromName(string name, out MassUnit unit)
Parameters
name
stringThe name of unit.
unit
MassUnitWhen 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 mass 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.
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(MassUnit, MassUnit)
Determines whether two specified instances of MassValue are equal.
public static bool operator ==(MassUnit left, MassUnit right)
Parameters
Returns
- bool
true
ifleft
is equal toright
; otherwise,false
.
operator !=(MassUnit, MassUnit)
Determines whether two specified instances of MassValue are equal.
public static bool operator !=(MassUnit left, MassUnit right)
Parameters
Returns
- bool
true
ifleft
is equal toright
; otherwise,false
.