This project takes the idea of temperature as a defined type in the .Net Framework.
The Temperature value type have the following features:
- Create instances in desire temperature scale: Celsius, Fahrenheit, Kelvin, and Rankine.
- Default temperature scale is Celsius.
- Min/Max value are ±1.7976931348623157E+308.
- Temperature value type have properties to allow quick conversion to Celsius, Fahrenheit, Kelvin, and Rankine from default defined scale.
- Implicit/explicit conversion for UInt16, UInt32, UInt64, Int16, Int32, Int64, Single, Decimal, and Double.
- Defined operator: + unary, - negation, - subtract, + addition, * multiplicity, / division, ==, !=, <, >, <=, and >=.
- Defined IComparable, IEquatable, IConvertible, and IFormattable.
The source code is written in C# and targeted for the .Net Framework 4.0 and later. Download the entire project and compile.
Once you have compiled the project reference the dll in your Visual Studio project. Then in your code file add the following to the collection of using statement.
using Ekstrand;
Creates a new instance of Temperature at default Celsius scale.
Temperature tempValue = new Temperature(23.5);
Create a new instance of Temperature with defined temperature scale and default value of 0.
Temperature tempValue = new Temperature(TemperatureScaleTypes.Celsius);
Create a new instance of Temperature with a value and defined scale.
Temperature tempValue = new Temperature(23.5, TemperatureScaleTypes.Fahrenheit);
Implicit conversion from integer to temperature
int value = 32
Temperature tempValue = new Temperature();
tempValue = value;
Operators
Temperature first = 55;
Temperature second = 60;
Temperature three = first + second;
if(three < 115)
{ ... }
else if(three >= 115)
{ ... }
...
MSDN-style code documentation can be found here.
1.0.0 Initial release into the wild.
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are always welcome.
Fred Ekstrand email: fredekstrandgithub@gmail.com
This project is licensed under the MIT License - see the LICENSE.md file for details.