Appearance
CurrencyCode
CurrencyCode is a value object for an ISO 4217 alphabetic currency code, accepted from a closed list of currencies in circulation.
Usage
csharp
var brl = CurrencyCode.Create(" brl "); // "BRL": trimmed and upper-cased
CurrencyCode.TryCreate("usd", out var usd);
CurrencyCode.IsValid("EUR"); // true
CurrencyCode.IsValid("XYZ"); // false| Member | Description |
|---|---|
Create(string?) | Normalizes and returns the code; throws ArgumentException when it is not in the list |
TryCreate(string?, out CurrencyCode) | Same, without the exception |
IsValid(string?) | Whether the normalized value is in the list |
Value / ToString() | The upper-case three-letter code |
Codes / Edition | The accepted set and the List One edition it came from |
Two codes with the same value are equal.
The list
The source is ISO 4217 List One, published by SIX Financial Information. Only currencies are accepted: fund codes and the X codes of metals, units of account and tests (for example XTS and XXX) are refused. The X codes that are currencies (XAF, XCD, XCG, XOF, XPF) are accepted. The type holds no exchange rate and no minor-unit digits.
A new edition of the list is a change to CurrencyCode.Codes and to nothing else.