NMoney 4.3.0

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

A lightweight and reliable library for representing and working with monetary values in .NET, based on ISO 4217 currency definitions.

NuGet Version NuGet Downloads

✨ Features

  • Strongly-typed monetary values
  • Full support for ISO 4217 currencies
  • Safe arithmetic operations (prevents mixing currencies)
  • Built-in rounding (major and minor units)
  • Value-type (struct) for performance and immutability
  • Designed for financial and business applications

πŸš€ Quick Start

Install NuGet package

dotnet add package NMoney

Write code

using NMoney;
using Iso4217List = NMoney.Iso4217.CurrencySet;

var price = Iso4217List.USD.Money(10m);
var quantity = 3;

var total = price * quantity;

Console.WriteLine(total); // 30 USD

πŸ’° Core Concepts

Money

Money is a value type that represents a monetary amount.

It consists of:

  • A decimal amount
  • A currency (ICurrency)

Key behaviors

  • Immutable
  • Supports arithmetic operations
  • Throws an exception when mixing different currencies

Currency

ICurrency represents a currency and provides:

  • Name (e.g. "US Dollar")
  • ISO 4217 code (e.g. "USD")
  • Number of decimal places for minor units (e.g. 2 for cents)
  • Currency symbol (e.g. "$")

Currency Sets

CurrencySet represents a collection of currencies used for:

  • list of currencies used in the application
  • serialization and deserialization
using NMoney;
using Iso4217List = NMoney.Iso4217.CurrencySet;

ICurrencySet actualSet =
new CurrencySet([
   Iso4217List.CNY,
   Iso4217List.RUB,
   Iso4217List.INR,  
   new Currency("BTC", 0.01m, "β‚Ώ")
]);

Console.WriteLine(actualSet.TryParse("CNY")); // Yuan Renminbi

🌍 ISO 4217

Currency definitions are based on the official ISO 4217 standard.

Updates are sourced from:

The XML list is used to generate currency definitions in C#.

Iso4217.CurrencySet provides:

  • All active ISO 4217 currencies
  • Obsolete currencies (where applicable)
using NMoney;

var allIso4217Set = NMoney.Iso4217.CurrencySet.Instance;

Console.WriteLine(allIso4217Set.TryParse("AUD")); //Australian Dollar

πŸ”’ Operations

Arithmetic

var usd = NMoney.Iso4217.CurrencySet.USD;

var usd10 = usd.Money(10m);
var usd15 = usd.Money(15m);

var sum = usd10 + usd15;     // 25 USD
var diff = usd15 - usd10;    // 5 USD
var scaled = usd10 * 2;      // 20 USD
var divided = usd15 / 3;     // 5 USD

Currency safety

var usd = NMoney.Iso4217.CurrencySet.USD.Money(10m);
var eur = NMoney.Iso4217.CurrencySet.EUR.Money(10m);

var invalid = usd + eur; // throws InvalidOperationException

Comparison

var usd = NMoney.Iso4217.CurrencySet.USD;

var usd10 = usd.Money(10m);
var usd15 = usd.Money(15m);

usd10 == usd15; // false
usd10 < usd15;  // true

usd10 == CurrencySet.EUR.Money(10m); // false
usd10 > CurrencySet.EUR.Money(10m);  // throws InvalidOperationException

Aggregation

var usd = NMoney.Iso4217.CurrencySet.USD;

var total = Money.Zero;

total += usd.Money(10m);
total += usd.Money(15m);

// total = 25 USD

Money.Zero represents a neutral monetary value used as a starting point for aggregations.

When combined with another Money value, it adopts that value’s currency.

Rounding

var value = NMoney.Iso4217.CurrencySet.USD.Money(20.953m);

value.CeilingMajorUnit(); // 21 USD
value.FloorMajorUnit();   // 20 USD
value.CeilingMinorUnit(); // 20.96 USD
value.FloorMinorUnit();   // 20.95 USD

🧩 Design Principles

  • Correctness over convenience β€” prevents invalid monetary operations
  • Explicit currency handling β€” no implicit conversions
  • Precision β€” uses decimal for financial accuracy
  • Immutability β€” safe for concurrent and functional scenarios

πŸ“¦ Serialization

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 is compatible.  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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NMoney:

Package Downloads
NMoney.Bson

Bson serialization and MongoDB query rendering for NMoney

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.3.0 140 4/16/2026
4.2.0 652 5/16/2025
4.1.0 5,212 12/28/2024
4.0.0 2,797 2/18/2024
3.1.0 13,434 11/29/2020
3.0.0 11,022 11/5/2018
2.0.0 1,677 10/13/2017