Temperature Structure |
The Temperature type exposes the following members.
Name | Description | |
---|---|---|
Temperature | Constructs a Temperature with the specified units and value (rounded to the nearest 0.1 degrees). |
Name | Description | |
---|---|---|
IsCelsius | Returns true if this temperature has Celsius units; false otherwise. | |
IsFahrenheit | Returns true if this temperature has Fahrenheit units; false otherwise. | |
Unit | Gets the TemperatureUnit of this temperature. | |
Value | Returns a double representation of the 0.1-precision number stored internally. |
Name | Description | |
---|---|---|
Celsius | Returns a Temperature with the specified Celsius temperature rounded to the nearest 0.1 C. | |
CelsiusRange | 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. | |
CompareTo | Compares two Temperature objects for low-to-high ordering. | |
Equals(Object) |
Two Temperature instances can only be equal if they have the
same units and temperature value.
(Overrides ValueTypeEquals(Object)) | |
Equals(Temperature) | Two Temperature instances can only be equal if they have the same units and temperature value. | |
Fahrenheit | Returns a Temperature with the specified Fahrenheit temperature rounded to the nearest 0.1 F. | |
FahrenheitRange | 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. | |
GetHashCode |
Overridden to ensure consistency with Equals.
(Overrides ValueTypeGetHashCode) | |
ToNumericString | 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. | |
ToString |
Returns a non-null, non-empty string representation of this instance for logging and debugging purposes.
(Overrides ValueTypeToString) |
Name | Description | |
---|---|---|
Equality(Temperature, Temperature) | Determines whether two specified Temperature instances are equal (in both Unit and Value). | |
GreaterThan(Temperature, Temperature) | Determines whether one specified Temperature is greater than another specified Temperature. | |
GreaterThanOrEqual(Temperature, Temperature) | Determines whether one specified Temperature is greater than or equal to another specified Temperature. | |
Inequality(Temperature, Temperature) | Determines whether two specified Temperature instances are not equal (in Unit or in Value). | |
LessThan(Temperature, Temperature) | Determines whether one specified Temperature is less than another specified Temperature. | |
LessThanOrEqual(Temperature, Temperature) | Determines whether one specified Temperature is less than or equal to another specified Temperature. |
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.
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).