Clone wiki

M42 Financial / Home

M42 Financial

Welcome to the M42 Financial project. Its goal:

A C#/.NET library for working with monetary units and currency in a simple, intuitive way.

Features

  • Supports all active official ISO-4217 currencies out of the box.
  • Create your own Currency.
  • Work with culture-independent Money value.
  • Supports all operations that decimal supports.
  • 128-bit decimal internal representation.
  • Serializable.
  • Easily convert between Money and integers or decimals.

Why this library?

If you've ever tried to work with currencies in native .NET, you might have noticed that there is hardly any support for it. Only the unitless decimal type is available, and the current culture determines the currency. M42 Financial tries to provide proper, culture-independent support for currencies.

Installation

Use NuGet to install the latest version in your project:

PM> Install-Package M42.Financial

Supported platforms

This library is a Portable Class Library. It supports the following platforms:

  • .NET for Windows Store apps
  • .NET Framework 4.5 or newer
  • Silverlight 5 or newer
  • Windows Phone 8

Example

Here a quick example that shows how to create a new instance of Money, use an existing Currency, and exchange the value to another currency:

Money myEuros = new Money(1337.42m, Currency.EUR);
Console.WriteLine("I have: " + myEuros);

CurrencyPair exchangeRate = new CurrencyPair(Currency.EUR, Currency.USD, 1.3024m);
Money myDollars = exchangeRate.Sell(myEuros);
Console.WriteLine("which equals: " + myDollars);

// Prints:
// I have: €1,337.42
// which equals: $1,741.86

Find more examples in the M42.Financial.Tests\Examples folder.

Troubleshooting

If you have any issues, encounter a bug or want to request a feature, please have a look at the Issues page. If you can't find a similar issue, bug or feature request, you are welcome to add your own.

If you have coded improvements you want to share, please do a pull request.

Contact

This library is written by me, Daniel Pelsmaeker. You can contact me through BitBucket.

License

Software

Copyright (C) 2012-2013 Daniel Pelsmaeker

M42 Financial is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

M42 Financial is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Documentation

Copyright (C) 2012-2013 Daniel Pelsmaeker

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the file License.txt.

Updated