Energy Structure

Represents an energy measurement, in joules (i.e., watt-seconds), as a double-precision floating-point number.

Definition

Namespace: Gemstone.Units
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.110 -- Release Build+3e0464f4461df4d3e1175b13966eb47ff832554d
Inheritance
Object    ValueType    Energy
Implements
IComparable, IComparableEnergy, IComparableDouble, IConvertible, IEquatableEnergy, IEquatableDouble, IFormattable

Remarks

This class behaves just like a Double representing an energy in joules; 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 energy representations, specifically watt-hours, BTU, Celsius heat unit, liter-atmosphere, calorie, horsepower-hour, barrel of oil and ton of coal. Metric conversions are handled simply by applying the needed SI conversion factor, for example:

Example

Convert energy in joules to megajoules:
C#
public double GetMegajoules(Energy joules)
{
    return joules / SI.Mega;
}
This example converts megajoules to kilowatt-hours:
C#
public double GetKilowattHours(double megajoules)
{
    return (new Energy(megajoules * SI.Mega)).ToWattHours() / SI.Kilo;
}
This example converts kilowatt-hours to megawatt-hours:
C#
public double GetMegawattHours(double kilowattHours)
{
    return (kilowattHours * SI.Kilo) / SI.Mega;
}

Constructors

Energy Creates a new Energy.

Methods

CompareTo(Double) Compares this instance to a specified Double and returns an indication of their relative values.
CompareTo(Energy) Compares this instance to a specified Energy 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 Energy in joules.
ConvertTo Converts the Energy to the specified targetUnit.
Equals(Double) Returns a value indicating whether this instance is equal to a specified Double value.
Equals(Energy) Returns a value indicating whether this instance is equal to a specified Energy value.
Equals(Object) Returns a value indicating whether this instance is equal to a specified object.
(Overrides ValueTypeEquals(Object))
FromBarrelsOfOil Creates a new Energy value from the specified value in equivalent barrels of oil.
FromBTU Creates a new Energy value from the specified value in BTU (International Table).
FromCalories Creates a new Energy value from the specified value in calories (International Table).
FromCelsiusHeatUnits Creates a new Energy value from the specified value in Celsius heat units (International Table).
FromHorsepowerHours Creates a new Energy value from the specified value in horsepower-hours.
FromLitersAtmosphere Creates a new Energy value from the specified value in liters-atmosphere.
FromTonOfCoal Creates a new Energy value from the specified value in equivalent tons of coal.
FromWattHours Creates a new Energy value from the specified value in watt-hours.
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 Energy equivalent.
Parse(String, NumberStyles) Converts the string representation of a number in a specified style to its Energy equivalent.
Parse(String, IFormatProvider) Converts the string representation of a number in a specified culture-specific format to its Energy equivalent.
Parse(String, NumberStyles, IFormatProvider) Converts the string representation of a number in a specified style and culture-specific format to its Energy equivalent.
ToBarrelsOfOil Gets the Energy value in equivalent barrels of oil.
ToBTU Gets the Energy value in BTU (International Table).
ToCalories Gets the Energy value in calories (International Table).
ToCelsiusHeatUnits Gets the Energy value in Celsius heat units (International Table).
ToCoulombs Gets the Charge value in coulombs given the specified volts.
ToHorsepowerHours Gets the Energy value in horsepower-hours.
ToLitersAtmosphere Gets the Energy value in liters-atmosphere.
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.
ToTonsOfCoal Gets the Energy value in equivalent tons of coal.
ToWattHours Gets the Energy value in watt-hours.
TryParse(String, Energy) Converts the string representation of a number to its Energy equivalent. A return value indicates whether the conversion succeeded or failed.
TryParse(String, NumberStyles, IFormatProvider, Energy) Converts the string representation of a number in a specified style and culture-specific format to its Energy equivalent. A return value indicates whether the conversion succeeded or failed.

Operators

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

Fields

MaxValueRepresents the largest possible value of an Energy. This field is constant.
MinValueRepresents the smallest possible value of an Energy. 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