Mass Structure

Represents a mass measurement, in kilograms, as a double-precision floating-point number.

Definition

Namespace: Gemstone.Units
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.128 -- Release Build+d050cfc5563c89a1188cc3c6b2d417530856f490
[SerializableAttribute]
public struct Mass : IComparable, IFormattable, 
	IConvertible, IComparable<Mass>, IComparable<double>, IEquatable<Mass>, 
	IEquatable<double>
Inheritance
Object    ValueType    Mass
Implements
IComparable, IComparableMass, IComparableDouble, IConvertible, IEquatableMass, IEquatableDouble, IFormattable

Remarks

This class behaves just like a Double representing a mass in kilograms; it is implicitly castable to and from a Double and therefore can be generally used "as" a double, but it has the advantage of handling conversions to and from other mass representations, specifically ounces, pounds and tons. Metric conversions are handled simply by applying the needed SI conversion factor, for example:

Example

Convert mass, in kilograms, to grams:
C#
public double GetGrams(Mass kilograms)
{
    return kilograms * SI.Kilo;
}
This example converts tons to pounds:
C#
public double GetPounds(double tons)
{
    return Mass.FromTons(tons).ToPounds();
}

Constructors

Mass Creates a new Mass.

Methods

CompareTo(Double) Compares this instance to a specified Double and returns an indication of their relative values.
CompareTo(Mass) Compares this instance to a specified Mass and returns an indication of their relative values.
CompareTo(Object) Compares this instance to a specified object and returns an indication of their relative values.
ConvertFrom Converts the value in the specified sourceUnit to a new Mass in kilograms.
ConvertTo Converts the Mass to the specified targetUnit.
Equals(Double) Returns a value indicating whether this instance is equal to a specified Double value.
Equals(Mass) Returns a value indicating whether this instance is equal to a specified Mass value.
Equals(Object) Returns a value indicating whether this instance is equal to a specified object.
(Overrides ValueTypeEquals(Object))
FromLongTons Creates a new Mass value from the specified value in long tons.
FromMetricPounds Creates a new Mass value from the specified value in metric pounds.
FromMetricTons Creates a new Mass value from the specified value in metric tons.
FromOunces Creates a new Mass value from the specified value in ounces (avoirdupois).
FromPounds Creates a new Mass value from the specified value in pounds (avoirdupois).
FromTons Creates a new Mass value from the specified value in short tons.
GetHashCode Returns the hash code for this instance.
(Overrides ValueTypeGetHashCode)
GetTypeGets the Type of the current instance.
(Inherited from Object)
GetTypeCode Returns the TypeCode for value type Double.
Parse(String) Converts the string representation of a number to its Mass equivalent.
Parse(String, NumberStyles) Converts the string representation of a number in a specified style to its Mass equivalent.
Parse(String, IFormatProvider) Converts the string representation of a number in a specified culture-specific format to its Mass equivalent.
Parse(String, NumberStyles, IFormatProvider) Converts the string representation of a number in a specified style and culture-specific format to its Mass equivalent.
ToLongTons Gets the Mass value in long tons.
ToMetricPounds Gets the Mass value in metric pounds.
ToMetricTons Gets the Mass value in metric tons.
ToOunces Gets the Mass value in ounces (avoirdupois).
ToPounds Gets the Mass value in pounds (avoirdupois).
ToString Converts the numeric value of this instance to its equivalent string representation.
(Overrides ValueTypeToString)
ToString(IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information.
ToString(String) Converts the numeric value of this instance to its equivalent string representation, using the specified format.
ToString(String, IFormatProvider) Converts the numeric value of this instance to its equivalent string representation using the specified format and culture-specific format information.
ToTons Gets the Mass value in short tons.
TryParse(String, Mass) Converts the string representation of a number to its Mass equivalent. A return value indicates whether the conversion succeeded or failed.
TryParse(String, NumberStyles, IFormatProvider, Mass) Converts the string representation of a number in a specified style and culture-specific format to its Mass equivalent. A return value indicates whether the conversion succeeded or failed.

Operators

Addition(Mass, Mass) Returns computed sum of values.
Division(Mass, Mass) Returns computed division of values.
Equality(Mass, Mass) Compares the two values for equality.
Exponent(Mass, Mass) Returns result of first value raised to mass of second value.
GreaterThan(Mass, Mass) Returns true if left value is greater than right value.
GreaterThanOrEqual(Mass, Mass) Returns true if left value is greater than or equal to right value.
(Double to Mass) Implicitly converts value, represented in kilograms, to a Mass.
(Mass to Double) Implicitly converts Mass, represented in kilograms, to a Double.
Inequality(Mass, Mass) Compares the two values for inequality.
LessThan(Mass, Mass) Returns true if left value is less than right value.
LessThanOrEqual(Mass, Mass) Returns true if left value is less or equal to than right value.
Modulus(Mass, Mass) Returns computed remainder after dividing first value by the second.
Multiply(Mass, Mass) Returns computed product of values.
Subtraction(Mass, Mass) Returns computed difference of values.

Fields

MaxValueRepresents the largest possible value of an Mass. This field is constant.
MinValueRepresents the smallest possible value of an Mass. This field is constant.

Extension Methods

GetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
GetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)

See Also