TeixeiraSoftware.Finance.Currency 4.0.0

A simple cross platform currency class that follows the ISO 4217 standard.

There is a newer version of this package available.
See the version list below for details.
Install-Package TeixeiraSoftware.Finance.Currency -Version 4.0.0
dotnet add package TeixeiraSoftware.Finance.Currency --version 4.0.0
<PackageReference Include="TeixeiraSoftware.Finance.Currency" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TeixeiraSoftware.Finance.Currency --version 4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

TeixeiraSoftware.Finance.Currency

TeixeiraSoftware.Finance.Currency Tweet

Build status
license
Pull Requests
NuGet

A simple cross platform currency class library for .Net, that follows the ISO 4217 standard.

The implementation of this library is compatible with .Net Standard 2.0 (see https://docs.microsoft.com/en-us/dotnet/standard/net-standard for details).

This package depends on TeixeiraSoftware.Finance.Money

Installation

Install through NuGet Package Manager:

Install-Package TeixeiraSoftware.Finance.Currency

Usage

First of all, import the namespace, for convenience:

using TeixeiraSoftware.Finance;

Instantiation

Then, you can get a currency instance by three different ways:

  • Calling a factory property, where XXX is the three letters ISO code of the currency:
var currency = Currency.XXX;
  • Using the ByAlphabeticCode method, where, again, XXX is the three letters ISO code of the currency:
var currency = Currency.ByAlphabeticCode("XXX");
  • Using the ByNumericCode method, where 999 is the three numbers ISO code of the currency:
// Note that the numeric code is a string
var currency = Currency.ByNumericCode("999");

Properties

The Currency class have four read only properties:

public struct Currency
{
    // The ISO name of the currency
    public string Name { get; }

    // The 3 letters ISO code of the currency
    public string AlphabeticCode { get; }

    // The numeric ISO code of the currency
    public string NumericCode { get; }

    // The ISO minor units of the currency
    public byte MinorUnits { get; }
}

Comparing currencies

The available comparison operators are == and !=. The .Equals method is available also.

// returns true
var areCurrenciesEquivalent = (Currency.XXX == Currency.XXX);

// returns false
var areCurrenciesEquivalent = (Currency.XXX != Currency.XXX);

Listing all the currencies

You can use the Currency.AllCurrencies property to get a list of all the currencies:

var allCurrencies = Currency.AllCurrencies;

foreach (var currency in allCurrencies)
{
    var currencyName = currency.Name;
    var currencyISOAlphabeticCode = currency.AlphabeticCode;
    var currencyISONumericCode = currency.NumericCode;
    var currencyMinorUnits = currency.MinorUnits;
}

Contributing

I'm currently looking for help to improve the project. You can see some topics that you can help with in the issues section of the project's GitHub page.
You can also contribute by doing unit tests, documentation, making pull requests or sharing the project.

TeixeiraSoftware.Finance.Currency

TeixeiraSoftware.Finance.Currency Tweet

Build status
license
Pull Requests
NuGet

A simple cross platform currency class library for .Net, that follows the ISO 4217 standard.

The implementation of this library is compatible with .Net Standard 2.0 (see https://docs.microsoft.com/en-us/dotnet/standard/net-standard for details).

This package depends on TeixeiraSoftware.Finance.Money

Installation

Install through NuGet Package Manager:

Install-Package TeixeiraSoftware.Finance.Currency

Usage

First of all, import the namespace, for convenience:

using TeixeiraSoftware.Finance;

Instantiation

Then, you can get a currency instance by three different ways:

  • Calling a factory property, where XXX is the three letters ISO code of the currency:
var currency = Currency.XXX;
  • Using the ByAlphabeticCode method, where, again, XXX is the three letters ISO code of the currency:
var currency = Currency.ByAlphabeticCode("XXX");
  • Using the ByNumericCode method, where 999 is the three numbers ISO code of the currency:
// Note that the numeric code is a string
var currency = Currency.ByNumericCode("999");

Properties

The Currency class have four read only properties:

public struct Currency
{
    // The ISO name of the currency
    public string Name { get; }

    // The 3 letters ISO code of the currency
    public string AlphabeticCode { get; }

    // The numeric ISO code of the currency
    public string NumericCode { get; }

    // The ISO minor units of the currency
    public byte MinorUnits { get; }
}

Comparing currencies

The available comparison operators are == and !=. The .Equals method is available also.

// returns true
var areCurrenciesEquivalent = (Currency.XXX == Currency.XXX);

// returns false
var areCurrenciesEquivalent = (Currency.XXX != Currency.XXX);

Listing all the currencies

You can use the Currency.AllCurrencies property to get a list of all the currencies:

var allCurrencies = Currency.AllCurrencies;

foreach (var currency in allCurrencies)
{
    var currencyName = currency.Name;
    var currencyISOAlphabeticCode = currency.AlphabeticCode;
    var currencyISONumericCode = currency.NumericCode;
    var currencyMinorUnits = currency.MinorUnits;
}

Contributing

I'm currently looking for help to improve the project. You can see some topics that you can help with in the issues section of the project's GitHub page.
You can also contribute by doing unit tests, documentation, making pull requests or sharing the project.

Release Notes

First release.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
4.1.0 2,477 4/18/2019
4.0.3 2,874 12/11/2018
4.0.2 1,420 3/28/2018
4.0.1 337 2/23/2018
4.0.0 312 2/23/2018