Repository navigation
Home
Fluent temperature unit conversion for .NET 10+ — metric, US customary, and historical scales, all built on a single strongly-typed Temperature struct.
dotnet add package MarcusMedina.Units.TemperatureThis one, like several of its siblings, came from watching students struggle through their exercises. Temperature conversions look simple until you're the one trying to explain why Fahrenheit needs that strange 459.67 offset, or why Réaumur splits the freezing-to-boiling range into 80 degrees instead of 100. Coding each scale out properly was how I made sure I actually understood what I was about to explain, rather than just repeating a formula from the textbook. I wanted each unit conversion broken into the same small, obvious steps I'd walk a student through by hand, not buried inside a single formula.
-
New to C#? A clean example of a fluent conversion API, including a deliberate case where an operator (
+on two absolute temperatures) is marked[Obsolete]because it's physically meaningless — worth reading if you want to see how a library can guide correct usage. -
Need real conversions? Every scale is backed by an explicit, documented formula against Kelvin — no guessing which raw
doublemeans what.
using MarcusMedina.Units.Temperature.Metric;
using MarcusMedina.Units.Temperature.Historical;
Temperature boiling = 100.DegreesCelsius();
Temperature oldScale = 80.DegreesReaumur();
double fahrenheit = boiling.ToFahrenheit(); // 212
double celsius = oldScale.ToCelsius(); // 100
Temperature warmer = boiling - 10.DegreesCelsius();
bool hotter = boiling > oldScale;