Philiprehberger.UnitConverter 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Philiprehberger.UnitConverter --version 0.1.0
                    
NuGet\Install-Package Philiprehberger.UnitConverter -Version 0.1.0
                    
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="Philiprehberger.UnitConverter" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Philiprehberger.UnitConverter" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Philiprehberger.UnitConverter" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Philiprehberger.UnitConverter --version 0.1.0
                    
#r "nuget: Philiprehberger.UnitConverter, 0.1.0"
                    
#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.
#:package Philiprehberger.UnitConverter@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Philiprehberger.UnitConverter&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Philiprehberger.UnitConverter&version=0.1.0
                    
Install as a Cake Tool

Philiprehberger.UnitConverter

NuGet CI License: MIT

Type-safe unit conversions between length, weight, temperature, volume, data size, and speed with formatting.

Requirements

  • .NET 8.0 or later

Installation

dotnet add package Philiprehberger.UnitConverter

Usage

Length Conversion

using Philiprehberger.UnitConverter;

double miles = Convert.From(5.0, Length.Kilometers).To(Length.Miles);
// 3.106855...

Temperature Conversion

using Philiprehberger.UnitConverter;

double fahrenheit = Convert.From(100.0, Temperature.Celsius).To(Temperature.Fahrenheit);
// 212.0

double kelvin = Convert.From(0.0, Temperature.Celsius).To(Temperature.Kelvin);
// 273.15

Data Size Formatting

using Philiprehberger.UnitConverter;

string result = Convert.Format(2_500_000.0, DataSize.Bytes, DataSize.MB, "F2");
// "2.38 MB"

API

Member Description
Convert.From(double value, IUnit unit) Starts a conversion from the given value and unit, returns a ConversionBuilder.
Convert.Format(double value, IUnit from, IUnit to, string? format) Converts and returns a formatted string with the target unit symbol.
ConversionBuilder.To(IUnit target) Completes the conversion and returns the result as a double.
IUnit Interface representing a unit with Name, Symbol, ToBase, and FromBase.
Length Meters, Kilometers, Centimeters, Millimeters, Inches, Feet, Yards, Miles.
Weight Kilograms, Grams, Milligrams, Pounds, Ounces, Tons.
Temperature Celsius, Fahrenheit, Kelvin.
Volume Liters, Milliliters, Gallons, Quarts, Cups, FluidOunces.
DataSize Bytes, KB, MB, GB, TB, PB.
Speed MetersPerSecond, KilometersPerHour, MilesPerHour, Knots.

Development

# Build
dotnet build src/Philiprehberger.UnitConverter.csproj --configuration Release

# Pack
dotnet pack src/Philiprehberger.UnitConverter.csproj --configuration Release -o out

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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
0.2.0 139 4/1/2026
0.1.2 116 3/23/2026
0.1.1 106 3/23/2026
0.1.0 110 3/21/2026