Click or drag to resize

Temperature Structure

Defines a temperature value, typically the base temperature of a degree-day calculation.

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

The Temperature type exposes the following members.

Constructors
  NameDescription
Public methodTemperature(Double, TemperatureUnit)
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.
Public propertyIsFahrenheit
Returns true if this temperature has Fahrenheit units.
Public propertyUnit
Gets the unit of this temperature.
Public propertyValue
Returns a double representation of the 0.1 precision number stored internally.
Top
Methods
  NameDescription
Public methodStatic memberCelsius(Double)
Returns a Temperature with the specified Celsius temperature rounded to the nearest 0.1 C.
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(Double)
Returns a Temperature with the specified Fahrenheit temperature rounded to the nearest 0.1 F.
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.
Public operatorStatic memberInequality(Temperature, Temperature)
Determines whether two specified Temperature instances are not equal.
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