Click or drag to resize

Temperature Structure

Defines a temperature value, typically the base temperature of a degree-day calculation.
Inheritance Hierarchy
SystemObject
  SystemValueType
    DegreeDays.Api.DataTemperature

Namespace: DegreeDays.Api.Data
Assembly: DegreeDays (in DegreeDays.dll) Version: 1.4
Syntax
public struct Temperature : IEquatable<Temperature>, 
	IComparable<Temperature>

The Temperature type exposes the following members.

Constructors
 NameDescription
Public methodTemperature Constructs a Temperature with the specified units and value (rounded to the nearest 0.1 degrees).
Top
Properties
 NameDescription
Public propertyIsCelsius Returns true if this temperature has Celsius units; false otherwise.
Public propertyIsFahrenheit Returns true if this temperature has Fahrenheit units; false otherwise.
Public propertyUnit Gets the TemperatureUnit of this temperature.
Public propertyValue Returns a double representation of the 0.1-precision number stored internally.
Top
Methods
 NameDescription
Public methodStatic memberCelsius Returns a Temperature with the specified Celsius temperature rounded to the nearest 0.1 C.
Public methodStatic memberCelsiusRange Returns a non-null low-to-high-sorted ICollection of temperatures, with Celsius values running from firstValue to lastValue (inclusive), and the specified step between each consecutive temperature.
Public methodCompareTo Compares two Temperature objects for low-to-high ordering.
Public methodEquals(Object) Two Temperature instances can only be equal if they have the same units and temperature value.
(Overrides ValueTypeEquals(Object))
Public methodEquals(Temperature) Two Temperature instances can only be equal if they have the same units and temperature value.
Public methodStatic memberFahrenheit Returns a Temperature with the specified Fahrenheit temperature rounded to the nearest 0.1 F.
Public methodStatic memberFahrenheitRange Returns a non-null low-to-high-sorted ICollection of temperatures, with Fahrenheit values running from firstValue to lastValue (inclusive), and the specified step between each consecutive temperature.
Public methodGetHashCode Overridden to ensure consistency with Equals.
(Overrides ValueTypeGetHashCode)
Public methodToNumericString Returns a non-null, non-empty string representation of the numeric base-temperature value, like "50" or "15.5" or "-5" or "33.1", in a format suitable for insertion into the appropriate unit-specific element(s) of the request XML.
Public methodToString Returns a non-null, non-empty string representation of this instance for logging and debugging purposes.
(Overrides ValueTypeToString)
Top
Operators
 NameDescription
Public operatorStatic memberEquality(Temperature, Temperature) Determines whether two specified Temperature instances are equal (in both Unit and Value).
Public operatorStatic memberGreaterThan(Temperature, Temperature) Determines whether one specified Temperature is greater than another specified Temperature.
Public operatorStatic memberGreaterThanOrEqual(Temperature, Temperature) Determines whether one specified Temperature is greater than or equal to another specified Temperature.
Public operatorStatic memberInequality(Temperature, Temperature) Determines whether two specified Temperature instances are not equal (in Unit or in Value).
Public operatorStatic memberLessThan(Temperature, Temperature) Determines whether one specified Temperature is less than another specified Temperature.
Public operatorStatic memberLessThanOrEqual(Temperature, Temperature) Determines whether one specified Temperature is less than or equal to another specified Temperature.
Top
Remarks

To create a Temperature instance you can use the static factory methods Celsius(Double) and Fahrenheit(Double). For example:

Temperature celsiusTemp = Temperature.Celsius(15.5);
Temperature fahrenheitTemp = Temperature.Fahrenheit(65);

You can pass a temperature into a Calculation to define the base temperature that that Calculation should use to calculate degree days. Use a Celsius temperature for Celsius degree days, and a Fahrenheit temperature for Fahrenheit degree days.

Rounding

This class enables temperatures to be defined to the nearest 0.1 degrees (either 0.1 C or 0.1 F). Given the limitations of temperature-recording equipment and methods, it is meaningless to consider temperature differences smaller than this.

When creating a Temperature object, you can pass in any double value within the maximum and minimum limits set by the temperature unit. But the value you pass in will always be rounded to the nearest 0.1 degrees.

For example, a Celsius Temperature created with a value of 15.5 will be equal to one created with 15.456 or 15.543. And a Fahrenheit Temperature created with 65 will be equal to one created with 64.96 or 65.04.

One benefit of this is that you can easily define a range of base temperatures in a loop without worrying too much about the inaccuracies of floating-point arithmetic. The automatic rounding should correct any such issues (e.g. rounding 69.9998 up to 70).

Thread Safety
Instances of this struct are immutable and safe for use from multiple threads at once.
See Also