TeixeiraSoftware.Finance.Currency 4.1.0

dotnet add package TeixeiraSoftware.Finance.Currency --version 4.1.0                
NuGet\Install-Package TeixeiraSoftware.Finance.Currency -Version 4.1.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="TeixeiraSoftware.Finance.Currency" Version="4.1.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.1.0                
#r "nuget: TeixeiraSoftware.Finance.Currency, 4.1.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.
// Install TeixeiraSoftware.Finance.Currency as a Cake Addin
#addin nuget:?package=TeixeiraSoftware.Finance.Currency&version=4.1.0

// Install TeixeiraSoftware.Finance.Currency as a Cake Tool
#tool nuget:?package=TeixeiraSoftware.Finance.Currency&version=4.1.0                

TeixeiraSoftware.Finance.Currency

TeixeiraSoftware.Finance.Currency

Build status license Pull Requests NuGet BCH compliance

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.ICurrency.

Usage

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 struct have five read only properties:

public partial struct Currency : ICurrency, IComparable, IComparable<ICurrency>
{
    // The alphabetic ISO code of the currency
    // This property is always the same as AlphabeticCode
    public string Symbol { get; }

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

    // The alphabetic ISO code of the currency
    // This property is always the same as Symbol
    public string AlphabeticCode {
        get {
            return Symbol;
        }
    }

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

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

    // The sign symbol of the currency
    public string Sign { get; }
}

Comparing currencies

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

// 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;
    var currencySign = currency.Sign;
}

Contributing

You can see some topics that you can help with in the issues section of the project. You can also contribute by doing unit tests, writing documentation, making pull requests or sharing the project.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
4.1.0 1,394,318 4/18/2019
4.0.3 9,391 12/11/2018
4.0.2 3,391 3/28/2018
4.0.1 1,701 2/23/2018
4.0.0 1,671 2/23/2018

Added currency signs and sorting