Adds VolumeConcentration units for Units.NET on .NET nanoFramework. For .NET or .NET Core, use UnitsNet instead.
$ dotnet add package nanoFramework.UnitsNet.VolumeConcentration
This library brings Units.NET — the popular strongly typed units of measurement library — to the .NET nanoFramework platform. It is a fork of the original Units.NET project, adapted and maintained specifically for embedded and IoT devices running .NET nanoFramework.
Add strongly typed quantities to your nanoFramework code and get merrily on with your life. No more magic constants, no more second-guessing the unit of parameters and variables — even on microcontrollers.
Units.NET was created and is maintained by Andreas Gullberg Larsen. This nanoFramework port would not be possible without his excellent work on the original library. A huge thank you to Andreas and all the contributors to the Units.NET project!
If you are targeting full .NET (.NET Standard, .NET 6/8/9/10 or .NET Framework), please use the original UnitsNet NuGet package instead. This repository is specifically tailored for the constraints and capabilities of .NET nanoFramework.
Length, Mass, Temperature, Pressure, ElectricCurrent, and 130+ more quantity types.using UnitsNet;
// Construct a length
Length meter = Length.FromMeters(1);
// Convert to other units
double cm = meter.Centimeters; // 100
double feet = meter.Feet; // 3.28084
double inches = meter.Inches; // 39.3701
using UnitsNet;
// Pass quantity types instead of raw values — communicate intent clearly
string PrintSensorReading(Temperature temp)
{
return $"Temperature: {temp.DegreesCelsius:F1} °C ({temp.DegreesFahrenheit:F1} °F)";
}
// Construct from sensor reading
Temperature reading = Temperature.FromDegreesCelsius(23.5);
string output = PrintSensorReading(reading);
// "Temperature: 23.5 °C (74.3 °F)"
using UnitsNet;
Mass package = Mass.FromKilograms(1.5);
double grams = package.Grams; // 1500
double pounds = package.Pounds; // 3.30693
double ounces = package.Ounces; // 52.9109
using UnitsNet;
// Atmospheric pressure
Pressure atm = Pressure.FromAtmospheres(1);
double pascals = atm.Pascals; // 101325
double psi = atm.PoundsForcePerSquareInch; // 14.6959
// Vehicle speed
Speed speed = Speed.FromKilometersPerHour(120);
double mph = speed.MilesPerHour; // 74.5645
double ms = speed.MetersPerSecond; // 33.3333
// Electric current from a sensor
ElectricCurrent current = ElectricCurrent.FromAmperes(0.5);
double mA = current.Milliamperes; // 500
using UnitsNet;
// Read raw sensor values and wrap them in strongly typed quantities
Temperature ambientTemp = Temperature.FromDegreesCelsius(ReadTemperatureSensor());
RelativeHumidity humidity = RelativeHumidity.FromPercent(ReadHumiditySensor());
Pressure barometric = Pressure.FromHectopascals(ReadBarometricSensor());
// Now you can safely pass these around without mixing up units
Debug.WriteLine($"Ambient: {ambientTemp.DegreesCelsius:F1} °C");
Debug.WriteLine($"Humidity: {humidity.Percent:F0} %");
Debug.WriteLine($"Pressure: {barometric.Hectopascals:F1} hPa ({barometric.Millibars:F1} mbar)");
The same strongly typed units are available on other platforms, all based on the same unit definitions:
| Language | Name | Package | Repository | Maintainers |
|---|---|---|---|---|
| C# (.NET) | UnitsNet | NuGet | GitHub | @angularsen |
| JavaScript / TypeScript | unitsnet-js | npm | GitHub | @haimkastner |
| Python | unitsnet-py | pypi | GitHub | @haimkastner |
| Golang | unitsnet-go | pkg.go.dev | GitHub | @haimkastner |
For documentation, providing feedback, issues and finding out how to contribute please refer to the Home repo.
Join our Discord community here.
The list of contributors to this project can be found at CONTRIBUTORS.
The nanoFramework Units.NET library is licensed under the MIT license.
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.
This project is supported by the .NET Foundation.