Class Currency
Provides information about a currency, such as the currency code, localized names, symbol and rounding rules.
Implements
Namespace: Singulink.Globalization
Assembly: Singulink.Globalization.Currency.dll
Syntax
public class Currency : IFormattable
Constructors
| Name | Description |
|---|---|
| Currency(string, ICurrencyLocalizer) | Initializes a new instance of the Currency class using the specified localizer to provide localized currency names and symbols. |
| Currency(string, string, string?) | Initializes a new instance of the Currency class without localization support. |
Properties
| Name | Description |
|---|---|
| CashRoundingPolicy | Gets or initializes the rounding rules for cash amounts of this currency, which may differ from RoundingPolicy because of the
physical denominations that are in circulation, i.e. Canadian dollar cash amounts are rounded to the nearest |
| CurrencyCode | Gets the currency code assigned to the currency. This is typically a three-letter ISO code, such as |
| DecimalDigits | Gets the number of decimal digits that monetary amounts of this currency are rounded to. This is a convenience property that returns the DecimalDigits value of the currency's RoundingPolicy. |
| Name | Gets the invariant name of this currency. Returns the English name for system currencies. To get the localized name use GetLocalizedName(CultureInfo?). |
| RoundingPolicy | Gets or initializes the rounding rules for monetary amounts of this currency, which consist of the number of decimal digits and any additional
rounding increment. Defaults to Default ( |
| Symbol | Gets the invariant symbol of this currency. To get the localized symbol use GetLocalizedSymbol(CultureInfo?). |
Methods
| Name | Description |
|---|---|
| GetCurrency(ReadOnlySpan<char>) | Gets the currency associated with the specified currency code from the Default registry. |
| GetCurrency(string) | Gets the currency associated with the specified currency code from the Default registry. |
| GetLocalizedName(CultureInfo?) | Gets the localized name for the currency in the specified culture (or the current culture if no culture is provided). |
| GetLocalizedSymbol(CultureInfo?) | Gets the localized symbol for the currency in the specified culture (or the current culture if no culture is provided). |
| IsSymbolOrCodeParsable(string, out string?) | Checks whether the specified symbol/code can be parsed. If this method returns false, then adding a currency that uses the symbol/code to a currency registry will cause parsing operations that depend on the offending symbol/code to throw an `InvalidOperationException, as it may otherwise result in unpredictable parsing errors or unreliable/incorrect results. |
| ToString() | Returns the localized string representation of the currency containing the currency's name and currency code. |
| ToString(string?, CultureInfo?) | Returns a localized string representation of the currency using the specified format and culture. |
| TryGetCurrency(ReadOnlySpan<char>, out Currency) | Gets the currency associated with the specified currency code from the Default registry. |
| TryGetCurrency(string, out Currency) | Gets the currency associated with the specified currency code from the Default registry. |
| TryGetLocalCurrency(out Currency) | Gets the local currency for the current culture using the Default currency registry. Culture must be region-specific for this method to succeed. |
| TryGetLocalCurrency(CultureInfo, out Currency) | Gets the local currency for the specified culture using the Default currency registry. Culture must be region-specific for this method to succeed. |
| TryGetLocalCurrency(RegionInfo, out Currency) | Gets the local currency for the specified region using the Default currency registry. |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IFormattable.ToString(string?, IFormatProvider?) | Returns a localized string representation of the currency using the specified format and format provider. If the format provider is not a CultureInfo instance, it is ignored and the current culture is used instead. |