Monetary 2.0.0

dotnet add package Monetary --version 2.0.0
                    
NuGet\Install-Package Monetary -Version 2.0.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="Monetary" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Monetary" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Monetary" />
                    
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 Monetary --version 2.0.0
                    
#r "nuget: Monetary, 2.0.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 Monetary@2.0.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=Monetary&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Monetary&version=2.0.0
                    
Install as a Cake Tool

Monetary

Monetary is a .NET library to make working with money safer and easier, designed to make currency, precision, and domain intent explicit in financial code. It is based on Martin Fowler's Money Pattern.

"If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634" -- Bill Karwin

Problem

Primitive numeric types make money deceptively easy to represent and dangerously easy to misuse.

Using raw decimal, double, or float values throughout an application can lead to code that:

  • mixes values from different currencies without validation
  • loses the domain meaning behind an amount
  • scatters rounding, formatting, and precision rules across the codebase
  • treats financial operations like ordinary arithmetic
  • makes business rules harder to read, test, and audit

Money is not just a number. It is an amount in a currency, governed by business rules.

Approach

Monetary models money as a value object with currency awareness and clear operations. Instead of passing primitive amounts around, financial code can work with explicit domain concepts.

The goal is to make business logic read closer to the language of the domain:

var usd = Currencies.FromCurrencyCode("USD");
var eur = Currencies.FromCurrencyCode("EUR");

var pair = new CurrencyPair(usd!, eur!);

Currency-sensitive operations should be safe by default:

// Throws because an exchange pair must contain two different currencies.
var invalid = new CurrencyPair(Currencies.USD, Currencies.USD);

Design Goals

  • Represent money as an immutable value object.
  • Keep currency attached to every monetary amount.
  • Prevent accidental arithmetic across different currencies.
  • Centralize precision, rounding, and formatting behavior.
  • Provide predefined ISO-style currency metadata.
  • Provide APIs that make financial intent clear in application code.
  • Support domain-first business logic without leaking primitive money rules everywhere.

Building

From the repository root:

dotnet build src/Monetary/Monetary.csproj

Usage

Until the first rebuilt package is published, reference the project directly from another .NET project:

dotnet add reference path/to/Monetary/src/Monetary/Monetary.csproj

Package installation instructions will be added when a stable release is available.

Why This Exists

Financial code should make invalid states difficult to express. Monetary exists to replace scattered primitive money handling with small, explicit, testable domain objects that carry the rules of money with them.

License

This project is licensed under the terms included in the repository license file.

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
2.0.0 87 5/16/2026
1.2.0 1,031 4/20/2019
1.0.0 941 12/1/2018
0.2.0 944 11/10/2018
0.0.1 926 11/6/2018