RedStar.Amounts 4.1.5

.NET Standard 2.0
dotnet add package RedStar.Amounts --version 4.1.5
NuGet\Install-Package RedStar.Amounts -Version 4.1.5
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="RedStar.Amounts" Version="4.1.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RedStar.Amounts --version 4.1.5
#r "nuget: RedStar.Amounts, 4.1.5"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install RedStar.Amounts as a Cake Addin
#addin nuget:?package=RedStar.Amounts&version=4.1.5

// Install RedStar.Amounts as a Cake Tool
#tool nuget:?package=RedStar.Amounts&version=4.1.5

RedStar.Amounts

Build status

RedStar.Amounts contains classes to easily work with unit and amounts.

Too often, applications use integers, doubles, etc. to indicate distances, weights, and other measured values. This can cause problems because assumptions are made on the units, conversions have to be done, etc.

This can cause hard-to-trace bugs and leads to less readable code.

Say you have a public service (WCF, REST, ...) that takes in measurements from an external service. Which of the following do you prefer?

public class SomeService
{
    public void ReportMeasurement(double length, double height)
    {
        // external system sends values in meters, but we work with cm
        var lengthInCm = length * 100;
        var heightInCm = height * 100;
        var area = lengthInCm * heightInCm;
        ...
    }
}

Or this:

public class SomeService
{
    public void ReportMeasurement(Amount length, Amount height)
    {
        var area = length * height;
        ...
    }
}

In the second example, the area variable will automatically have a value and a unit. The unit will be m².

This makes it easier and more fail-proof to do calculations later.

Installation

RedStar.Amounts consists of three Nuget packages:

Packages are released according to semantic versioning and all latest versions should work together without any problems.

Documentation

You can find the latest documentation here.

.NET versions

This library targets .NET Standard 2.0.

Source, license

This code was taken and built upon from CodeProject. Credit is due to Rudi Breedenraedt. The code is licensed under the CPOL.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on RedStar.Amounts:

Package Downloads
RedStar.Amounts.StandardUnits

Standard units to use with the RedStar.Amounts package. These contain units that are part of the International System of Units (or SI, from the French Système Internationale).

RedStar.Amounts.JsonNet

Custom converters for serializing and deseriazling RedStar.Amounts types to JSON using NewtonSoft's JSON.NET library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.1.5 246 10/17/2022
4.1.4 249 10/17/2022
4.1.3 251 10/17/2022
4.1.2 847 11/6/2019
4.1.1 716 7/10/2019
4.1.0 1,018 10/5/2018
4.0.0 752 9/11/2018
2.1.1 933 2/21/2018
2.0.0 1,274 11/6/2017
1.5.0 1,351 5/23/2016