Converter.Temperature 3.1.39

The ID prefix of this package has been reserved for one of the owners of this package by Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Converter.Temperature --version 3.1.39
NuGet\Install-Package Converter.Temperature -Version 3.1.39
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Converter.Temperature" Version="3.1.39" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Converter.Temperature --version 3.1.39
#r "nuget: Converter.Temperature, 3.1.39"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Converter.Temperature as a Cake Addin
#addin nuget:?package=Converter.Temperature&version=3.1.39

// Install Converter.Temperature as a Cake Tool
#tool nuget:?package=Converter.Temperature&version=3.1.39


Converter.Temperature This project was created to extract out the main conversion code from the Temperature Converter applications in the other repositories. I am using this as a way to show how my development skills have changed over the years, as I get to be a better developer.


These extension methods will convert different types of temperatures to other types.

Temperature types

  • Celsius
  • Fahrenheit
  • Kelvin
  • Gas
  • Rankine

Data types

  • int
  • long
  • float
  • double
  • string


I had a few ideas on how to do the extension methods but decided on using a fluent style.

Originally, the extensions looked like this:

    var tempToConvert = 34; // an int.
    var convertedTemp = tempToConvert.CelsiusToFahrenheit();

Then I thought that this looked a bit naf so, I went with setting up the from first, then the to. This follows the fluent pattern.

Now it is used like this:

    var tempToConvert = 34; // an int.
    var convertedTemp = tempToConvert.FromCelsius().ToFahrenheit();

The next stage for version 2 is to add an additional usage like this:

    var tempToConvert = 34; // an int.
    var convertedTemp = tempToConvert.From<Celsius>().To<Fahrenheit>();

What to do for edge cases

I'm working on what I want the library to do when an exception could be thrown. This is when we have the edge cases of values that are too small or too large for the type being converted to.


From a float type with a value close to the max value of a float, converted from Celsius to Fahrenheit. Because a Fahrenheit value is greater than the celsius value, then we can't convert correctly.

Should this throw an exception or just return the original value?

Well, returning the same value would seem like all is well, even though the converted value is wrong. Thinking about this means that for me, it should throw an exception for the calling application to handle.

If anyone has any better ideas, then I would be willing to change this behaviour.

More Information

For more information on the project and where it is heading, see the wiki.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.2.50 95 4/7/2024
3.1.39 88 3/23/2024
3.0.0 1,340 11/16/2022
2.1.1 433 6/3/2022
2.0.1 440 4/21/2022
2.0.0 260 1/8/2022
1.1.0 299 12/2/2021

See the details at the following link.

Pay particular attention to the changes made for Issue 60 in the release notes.