Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

money Build status

Yet another money class written in C#.

Features at a glance

  • Generic type for the amount of Money (including your custom type)
  • Unary arithmetic
  • Binary arithmetic with arbitrary numbers
  • Operations involving money of same currency
  • Operations involving money of different currencies

Supported operations

  • unary_operator Money
  • Money unary_operator
  • number binary_operator Money
  • Money binary_operator number
  • Money comparison_operator Money
  • Money binary_operator Money

Usage

Start by installing this nuget package.

Create:

// create money with decimal type of amount in my currency
var localMoney = new Money<decimal>(100m);

// create Australian dollars 
var aud = new Money<decimal>(42m, "AUD"); 

Operate:

var m1 = Money<decimal>(100m, "AUD");
var m2 = Money<decimal>(-42m, "AUD");
var m3 = Money<decimal>(3.1415m, "USD");
var m4 = Money<decimal>(1m, "EUR");
var m5 = Money<decimal>(8m, "GBP");

var audWallet = m1 + m2;
var audWalletValueAsMoney = audWallet.EvaluateWithoutConversion();

var multinationalWallet = (m1 % m5) + ((m2 * 3.5m) / m4) - (m3 * 9m);
var currencyConverter = new MyCurrencyConverter(); // this is some imaginary implementation of ICurrencyConverter<T>
var resultingMoneyInAUD = multinationalWallet.Evaluate(currencyConverter, "AUD");

For better explanation of features and other examples, visit this blog post.

About

A Money class written in C# for handling multi-currency arithmetic with generic type support.

Resources

License

Releases

No releases published

Languages

You can’t perform that action at this time.