Semantity 0.2.0
Package Description
See the version list below for details.
Install-Package Semantity -Version 0.2.0
dotnet add package Semantity --version 0.2.0
<PackageReference Include="Semantity" Version="0.2.0" />
paket add Semantity --version 0.2.0
Semantity
This package provides semantic types for physical quantities and units of measurement. They are typesafe and offer convenient extensions in order to use them for calculations and display.
Usage
The combination of operator overloading and extension methods simplifies the code drastically. Type inference allows for code like this:
var area = 40.MilliMeters() * 2.5.Meters();
var intensity = 100.Watts() / area;
// Prints "Intensity: 1000 W/m²"
Console.WriteLine($"Intesity: {intensity}");
Each quantity has a base unit and multiple other units to which they can be converted easily:
Memory memory = 2.KibiBytes();
Memory memoryInBytes = memory.In<Bytes>();
// Prints "Memory in bytes: 2048 B"
Console.WriteLine($"Memory in bytes: {memoryInBytes.Value} B");
Type safety prevents you from making mistakes like the following:
Length length = 0.4.Meters();
Length lengthInMeter = length.In<Hertz>(); // Won't compile!
Frequency frequency = length.In<Hertz>(); // Won't compile!
The current implementation includes the following quantities:
- Area
- Energy
- Frequency
- Intensity
- Length
- Memory
- Power
- Ratio
- Temperature
- Time
- Velocity
Semantity
This package provides semantic types for physical quantities and units of measurement. They are typesafe and offer convenient extensions in order to use them for calculations and display.
Usage
The combination of operator overloading and extension methods simplifies the code drastically. Type inference allows for code like this:
var area = 40.MilliMeters() * 2.5.Meters();
var intensity = 100.Watts() / area;
// Prints "Intensity: 1000 W/m²"
Console.WriteLine($"Intesity: {intensity}");
Each quantity has a base unit and multiple other units to which they can be converted easily:
Memory memory = 2.KibiBytes();
Memory memoryInBytes = memory.In<Bytes>();
// Prints "Memory in bytes: 2048 B"
Console.WriteLine($"Memory in bytes: {memoryInBytes.Value} B");
Type safety prevents you from making mistakes like the following:
Length length = 0.4.Meters();
Length lengthInMeter = length.In<Hertz>(); // Won't compile!
Frequency frequency = length.In<Hertz>(); // Won't compile!
The current implementation includes the following quantities:
- Area
- Energy
- Frequency
- Intensity
- Length
- Memory
- Power
- Ratio
- Temperature
- Time
- Velocity
Dependencies
-
.NETStandard 2.0
- No dependencies.
Used By
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.