MoneyInfo Class

Definition

Namespace: DataStandardizer.Money

Supplies the formatter and the currency formatting information used to format and parse monetary values.

public class MoneyInfo : IFormatProvider

Remarks

MoneyInfo is the monetary counterpart of CultureInfo: it is the format provider you pass where monetary formatting information is expected, and it resolves both the custom formatter and the CurrencyFormatInfo for a culture.

A CultureInfo may be passed wherever a MoneyInfo is expected. The monetary information for that culture is resolved on your behalf, so formatting a Money value looks the same as formatting an intrinsic numeric type.

Constructors

Constructor Notes
MoneyInfo() Culture-independent information.
MoneyInfo(Iso639Part1Language) Information for a language.
MoneyInfo(Iso639Part1Language, Iso3166Part1Alpha2Country) Information for a language and country.
MoneyInfo(Iso639Part1Language, Iso3166Part1Alpha3Country) As above, with a three-letter country code.
MoneyInfo(CultureInfo?) Information for a culture.

A combination of a language and a country which is not a culture known to the host falls back to the culture-independent information rather than failing.

Properties

Property Type Notes
CurrencyFormat CurrencyFormatInfo The currency formatting information. Setting it to null throws ArgumentNullException.
IsReadOnly bool true when the instance may not be modified.

Static members

Member Returns Notes
CurrentMoney MoneyInfo Read-only information for the current culture; tracks a change of culture.
InvariantMoney MoneyInfo Read-only culture-independent information.
GetMoneyInfo(CultureInfo?) MoneyInfo Read-only information for a culture. Calls for the same CultureInfo instance may share one instance.

Methods

Method Returns Notes
GetFormat(Type) object? Returns a formatter for ICustomFormatter, or the currency format for CurrencyFormatInfo.

Applies to

Targets netstandard1.1, netstandard2.0, and net10.0.

CurrentMoney is part of the API on netstandard2.0 and later only. On every target, including netstandard1.1, a Money value that is formatted or parsed without a provider uses the culture of the current thread.

See also


This site uses Just the Docs, a documentation theme for Jekyll.