CurrencyFormatter CurrencyFormatter CurrencyFormatter CurrencyFormatter Class

Formats and parses currencies.

Syntax

Declaration

public sealed class CurrencyFormatterpublic sealed class CurrencyFormatterPublic NotInheritable Class CurrencyFormatter

Remarks

If your app passes language tags used in this class to any National Language Support functions, it must first convert the tags by calling ResolveLocaleName.

Constructors summary

Creates a CurrencyFormatter object that is initialized with a currency identifier.

Creates a CurrencyFormatter object initialized with a currency identifier, language list, and geographic region.

Properties summary

Note

Currency may be read-only for releases after Windows 8.1. Instead, use a new CurrencyFormatter.

Gets the identifier for the currency to be used for formatting and parsing currency values.

Gets or sets the minimum number of digits to display for the fraction part of the currency value.

Gets the region that is used when formatting and parsing currency values.

Gets or sets the minimum number of digits to display for the integer part of the currency value.

Gets or sets whether the decimal point of the currency value should always be displayed.

Gets or sets whether the integer part of the currency value should be grouped.

Gets or sets whether -0 is formatted using the conventions for negative numbers or for positive numbers. (In the Latin numeral system, the choice is "-0" or "0".)

Gets the priority list of language identifiers that is used when formatting and parsing currency values.

Gets or sets whether the currency is formatted with the currency symbol or currency code.

Gets or sets the current rounding strategy to be used when formatting currency amounts.

Gets or sets the numbering system that is used to format and parse currency values.

Gets the geographic region that was most recently used to format or parse currency values.

Gets the language that was most recently used to format or parse currency values.

Gets or sets the current padding to significant digits when a currency amount is formatted.

Methods summary

Prepares the CurrencyFormatter object to format currency values with a specified rounding algorithm.

Returns a string representation of a Double currency value.

Returns a string representation of an Int64 currency value.

Returns a string representation of a UInt64 currency value.

Returns a string representation of a Double currency value.

Returns a string representation of an Int64 currency value.

Returns a string representation of a UInt64 currency value.

Attempts to parse a string representation of a Double currency value.

Attempts to parse a string representation of an integer currency value.

Attempts to parse a string representation of an unsigned integer currency value.

Constructors

  • CurrencyFormatter(System.String)
    CurrencyFormatter(System.String)
    CurrencyFormatter(System.String)
    CurrencyFormatter(System.String)

    Creates a CurrencyFormatter object that is initialized with a currency identifier.

    public CurrencyFormatter(System.String currencyCode)public CurrencyFormatter(System.String currencyCode)Public Function CurrencyFormatter(currencyCode As System.String) As

    Parameters

    • currencyCode
      System.String
      System.String
      System.String
      System.String

      The currency identifier to use when formatting and parsing currency values.

  • CurrencyFormatter(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String)
    CurrencyFormatter(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String)
    CurrencyFormatter(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String)
    CurrencyFormatter(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String)

    Creates a CurrencyFormatter object initialized with a currency identifier, language list, and geographic region.

    public CurrencyFormatter(System.String currencyCode,Windows.Foundation.Collections.IIterable{System.String} languages,System.String geographicRegion)public CurrencyFormatter(System.String currencyCode,Windows.Foundation.Collections.IIterable{System.String} languages,System.String geographicRegion)Public Function CurrencyFormatter(currencyCode As System.String,languages As Windows.Foundation.Collections.IIterable{System.String},geographicRegion As System.String) As

    Parameters

    • currencyCode
      System.String
      System.String
      System.String
      System.String

      The currency identifier to use when formatting and parsing currency values.

    • languages

      The list of language identifiers, in priority order, representing the choice of languages. See Remarks.

    • geographicRegion
      System.String
      System.String
      System.String
      System.String

      The identifier for the geographic region.

    Remarks

    In the case that the symbol for the provided currency is the same symbol as that of a different currency in the provided region (or the home region if none is provided), formatting may use a currency code even if the Mode property is UseSymbol. This is to avoid ambiguity. For example, @Windows.Globalization.NumberFormatting.CurrencyFormatter.#ctor(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String) ("USD", ["en"], "CA") creates a formatter that formats 3 as 3 CAD, even if the Mode property is UseSymbol. Similarly, @Windows.Globalization.NumberFormatting.CurrencyFormatter.#ctor(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String) ("CAD", ["en"], "US") creates a formatter that formats 3 as 3 USD.

    If your app passes language tags used in this class to any National Language Support functions, it must first convert the tags by calling ResolveLocaleName.

    Starting in : Language tags support the Unicode extensions "ca-" and "nu-". (See Unicode Key/Type Definitions.) Note that the "nu-" extension can affect the numeral system used by CurrencyFormatter objects.

Properties

  • Currency
    Currency
    Currency
    Currency
    Note

    Currency may be read-only for releases after Windows 8.1. Instead, use a new CurrencyFormatter.

    Gets the identifier for the currency to be used for formatting and parsing currency values.

    public string Currency { get; set; }public string Currency { get; set; }Public ReadWrite Property Currency As string

    Property Value

    • string
      string
      string
      string

      The currency identifier to use when formatting and parsing currency values.

  • FractionDigits
    FractionDigits
    FractionDigits
    FractionDigits

    Gets or sets the minimum number of digits to display for the fraction part of the currency value.

    public int FractionDigits { get; set; }public int FractionDigits { get; set; }Public ReadWrite Property FractionDigits As int

    Property Value

    • int
      int
      int
      int

      The minimum number of digits to display.

  • GeographicRegion
    GeographicRegion
    GeographicRegion
    GeographicRegion

    Gets the region that is used when formatting and parsing currency values.

    public string GeographicRegion { get; }public string GeographicRegion { get; }Public ReadOnly Property GeographicRegion As string

    Property Value

    • string
      string
      string
      string

      The region that is used.

  • IntegerDigits
    IntegerDigits
    IntegerDigits
    IntegerDigits

    Gets or sets the minimum number of digits to display for the integer part of the currency value.

    public int IntegerDigits { get; set; }public int IntegerDigits { get; set; }Public ReadWrite Property IntegerDigits As int

    Property Value

    • int
      int
      int
      int

      The minimum number of digits to display.

  • IsDecimalPointAlwaysDisplayed
    IsDecimalPointAlwaysDisplayed
    IsDecimalPointAlwaysDisplayed
    IsDecimalPointAlwaysDisplayed

    Gets or sets whether the decimal point of the currency value should always be displayed.

    public bool IsDecimalPointAlwaysDisplayed { get; set; }public bool IsDecimalPointAlwaysDisplayed { get; set; }Public ReadWrite Property IsDecimalPointAlwaysDisplayed As bool

    Property Value

    • bool
      bool
      bool
      bool

      True if the decimal point of the value should always be displayed, and false otherwise.

  • IsGrouped
    IsGrouped
    IsGrouped
    IsGrouped

    Gets or sets whether the integer part of the currency value should be grouped.

    public bool IsGrouped { get; set; }public bool IsGrouped { get; set; }Public ReadWrite Property IsGrouped As bool

    Property Value

    • bool
      bool
      bool
      bool

      True if the integer part of the value should be grouped, and false otherwise.

  • IsZeroSigned
    IsZeroSigned
    IsZeroSigned
    IsZeroSigned

    Gets or sets whether -0 is formatted using the conventions for negative numbers or for positive numbers. (In the Latin numeral system, the choice is "-0" or "0".)

    public bool IsZeroSigned { get; set; }public bool IsZeroSigned { get; set; }Public ReadWrite Property IsZeroSigned As bool

    Property Value

    • bool
      bool
      bool
      bool

      True if -0 is formatted as a negative number, and false if -0 is formatted as a positive number ("-0" or "0" in the Latin numeral system).

    Remarks

    You can set this property to specify that CurrencyFormatter display negative 0 as "-0". This enables the scenario where you wish to display "-0" when it represents the rounded value of some small negative value (such as -0.00001).

    This property defaults to false to be consistent with Windows 8 and Windows Server 2012, in which -0 was always formatted as "0".

  • Languages
    Languages
    Languages
    Languages

    Gets the priority list of language identifiers that is used when formatting and parsing currency values.

    public IVectorView<string> Languages { get; }public IVectorView<string> Languages { get; }Public ReadOnly Property Languages As IVectorView<string>

    Property Value

    • The priority list of language identifiers.

      Starting in : Language tags can support Unicode extensions. See the Remarks for the @Windows.Globalization.NumberFormatting.CurrencyFormatter.#ctor(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String) constructor.

    Remarks

    If your app passes language tags from this class to any National Language Support functions, it must first convert the tags by calling ResolveLocaleName.

  • Mode
    Mode
    Mode
    Mode

    Gets or sets whether the currency is formatted with the currency symbol or currency code.

    public CurrencyFormatterMode Mode { get; set; }public CurrencyFormatterMode Mode { get; set; }Public ReadWrite Property Mode As CurrencyFormatterMode

    Property Value

    Remarks

    See the remarks for @Windows.Globalization.NumberFormatting.CurrencyFormatter.#ctor(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String) for an explanation of how the currency code may be displayed when the currency symbol is ambiguous even if the Mode property is UseSymbol.

  • NumberRounder
    NumberRounder
    NumberRounder
    NumberRounder

    Gets or sets the current rounding strategy to be used when formatting currency amounts.

    public INumberRounder NumberRounder { get; set; }public INumberRounder NumberRounder { get; set; }Public ReadWrite Property NumberRounder As INumberRounder

    Property Value

    Remarks

    When a Format method is called, the appropriate rounding function from the number rounder object manipulates the input prior to it being formatted.

  • NumeralSystem
    NumeralSystem
    NumeralSystem
    NumeralSystem

    Gets or sets the numbering system that is used to format and parse currency values.

    public string NumeralSystem { get; set; }public string NumeralSystem { get; set; }Public ReadWrite Property NumeralSystem As string

    Property Value

    • string
      string
      string
      string

      A string that indicates the numeral system of the formatter, such as "Latn" for the Latin numeral system (0123456789) or "Arab" for the Arabic-Indic numeral system (٠١٢٣٤٥٦٧٨٩). See the supported NumeralSystem values.

  • ResolvedGeographicRegion
    ResolvedGeographicRegion
    ResolvedGeographicRegion
    ResolvedGeographicRegion

    Gets the geographic region that was most recently used to format or parse currency values.

    public string ResolvedGeographicRegion { get; }public string ResolvedGeographicRegion { get; }Public ReadOnly Property ResolvedGeographicRegion As string

    Property Value

    • string
      string
      string
      string

      The geographic region that was most recently used to format or parse currency values.

  • ResolvedLanguage
    ResolvedLanguage
    ResolvedLanguage
    ResolvedLanguage

    Gets the language that was most recently used to format or parse currency values.

    public string ResolvedLanguage { get; }public string ResolvedLanguage { get; }Public ReadOnly Property ResolvedLanguage As string

    Property Value

    • string
      string
      string
      string

      The language from the Languages that was most recently used to format or parse currency values.

      Starting in : Language tags can support Unicode extensions. See the Remarks for the @Windows.Globalization.NumberFormatting.CurrencyFormatter.#ctor(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String) constructor.

    Remarks

    If your app passes language tags from this class to any National Language Support functions, it must first convert the tags by calling ResolveLocaleName.

  • SignificantDigits
    SignificantDigits
    SignificantDigits
    SignificantDigits

    Gets or sets the current padding to significant digits when a currency amount is formatted.

    public int SignificantDigits { get; set; }public int SignificantDigits { get; set; }Public ReadWrite Property SignificantDigits As int

    Property Value

    • int
      int
      int
      int

      The number of significant digits.

    Remarks

    Trailing zeros are added to the format until the given number of significant digits is exhausted. If there are more digits, this property does not cause them to be truncated.

Methods

  • ApplyRoundingForCurrency(Windows.Globalization.NumberFormatting.RoundingAlgorithm)
    ApplyRoundingForCurrency(Windows.Globalization.NumberFormatting.RoundingAlgorithm)
    ApplyRoundingForCurrency(Windows.Globalization.NumberFormatting.RoundingAlgorithm)
    ApplyRoundingForCurrency(Windows.Globalization.NumberFormatting.RoundingAlgorithm)

    Prepares the CurrencyFormatter object to format currency values with a specified rounding algorithm.

    public void ApplyRoundingForCurrency(Windows.Globalization.NumberFormatting.RoundingAlgorithm roundingAlgorithm)public void ApplyRoundingForCurrency(Windows.Globalization.NumberFormatting.RoundingAlgorithm roundingAlgorithm)Public Function ApplyRoundingForCurrency(roundingAlgorithm As Windows.Globalization.NumberFormatting.RoundingAlgorithm) As void

    Parameters

    Remarks

    ApplyRoundingForCurrency(Windows.Globalization.NumberFormatting.RoundingAlgorithm) initializes NumberRounder to an IncrementNumberRounder object whose increment is set such that the inputs to Format(System.Double) will be rounded to the number of fraction digits established by Currency. The number of fraction digits can be obtained from the default value of the FractionDigits property.

  • Format(System.Double)
    Format(System.Double)
    Format(System.Double)
    Format(System.Double)

    Returns a string representation of a Double currency value.

    public string Format(System.Double value)public string Format(System.Double value)Public Function Format(value As System.Double) As string

    Parameters

    • value
      System.Double
      System.Double
      System.Double
      System.Double

      The Double currency value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the value.

    Remarks

    See the remarks for @Windows.Globalization.NumberFormatting.CurrencyFormatter.#ctor(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String) for an explanation of how the currency code may be displayed when the currency symbol is ambiguous.

  • Format(System.Int64)
    Format(System.Int64)
    Format(System.Int64)
    Format(System.Int64)

    Returns a string representation of an Int64 currency value.

    public string Format(System.Int64 value)public string Format(System.Int64 value)Public Function Format(value As System.Int64) As string

    Parameters

    • value
      System.Int64
      System.Int64
      System.Int64
      System.Int64

      The Int64 currency value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the value.

    Remarks

    See the remarks for @Windows.Globalization.NumberFormatting.CurrencyFormatter.#ctor(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String) for an explanation of how the currency code may be displayed when the currency symbol is ambiguous.

  • Format(System.UInt64)
    Format(System.UInt64)
    Format(System.UInt64)
    Format(System.UInt64)

    Returns a string representation of a UInt64 currency value.

    public string Format(System.UInt64 value)public string Format(System.UInt64 value)Public Function Format(value As System.UInt64) As string

    Parameters

    • value
      System.UInt64
      System.UInt64
      System.UInt64
      System.UInt64

      The UInt64 currency value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the value.

    Remarks

    See the remarks for @Windows.Globalization.NumberFormatting.CurrencyFormatter.#ctor(System.String,Windows.Foundation.Collections.IIterable{System.String},System.String) for an explanation of how the currency code may be displayed when the currency symbol is ambiguous.

  • FormatDouble(System.Double)
    FormatDouble(System.Double)
    FormatDouble(System.Double)
    FormatDouble(System.Double)

    Returns a string representation of a Double currency value.

    public string FormatDouble(System.Double value)public string FormatDouble(System.Double value)Public Function FormatDouble(value As System.Double) As string

    Parameters

    • value
      System.Double
      System.Double
      System.Double
      System.Double

      The Double currency value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the value.

  • FormatInt(System.Int64)
    FormatInt(System.Int64)
    FormatInt(System.Int64)
    FormatInt(System.Int64)

    Returns a string representation of an Int64 currency value.

    public string FormatInt(System.Int64 value)public string FormatInt(System.Int64 value)Public Function FormatInt(value As System.Int64) As string

    Parameters

    • value
      System.Int64
      System.Int64
      System.Int64
      System.Int64

      The Int64 currency value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the value.

  • FormatUInt(System.UInt64)
    FormatUInt(System.UInt64)
    FormatUInt(System.UInt64)
    FormatUInt(System.UInt64)

    Returns a string representation of a UInt64 currency value.

    public string FormatUInt(System.UInt64 value)public string FormatUInt(System.UInt64 value)Public Function FormatUInt(value As System.UInt64) As string

    Parameters

    • value
      System.UInt64
      System.UInt64
      System.UInt64
      System.UInt64

      The UInt64 currency value to be formatted.

    Returns

    • string
      string
      string
      string

      The UInt64 currency value to be formatted.

  • ParseDouble(System.String)
    ParseDouble(System.String)
    ParseDouble(System.String)
    ParseDouble(System.String)

    Attempts to parse a string representation of a Double currency value.

    public IReference<double> ParseDouble(System.String text)public IReference<double> ParseDouble(System.String text)Public Function ParseDouble(text As System.String) As IReference( Of double )

    Parameters

    • text
      System.String
      System.String
      System.String
      System.String

      The text to be parsed.

    Returns

    • If successful, a Double that corresponds to the string representation, and otherwise null.

  • ParseInt(System.String)
    ParseInt(System.String)
    ParseInt(System.String)
    ParseInt(System.String)

    Attempts to parse a string representation of an integer currency value.

    public IReference<long> ParseInt(System.String text)public IReference<long> ParseInt(System.String text)Public Function ParseInt(text As System.String) As IReference( Of long )

    Parameters

    • text
      System.String
      System.String
      System.String
      System.String

      The text to be parsed.

    Returns

    • If successful, an Int64 that corresponds to the string representation, and otherwise null.

  • ParseUInt(System.String)
    ParseUInt(System.String)
    ParseUInt(System.String)
    ParseUInt(System.String)

    Attempts to parse a string representation of an unsigned integer currency value.

    public IReference<ulong> ParseUInt(System.String text)public IReference<ulong> ParseUInt(System.String text)Public Function ParseUInt(text As System.String) As IReference( Of ulong )

    Parameters

    • text
      System.String
      System.String
      System.String
      System.String

      The text to be parsed.

    Returns

    • If successful, a UInt64 that corresponds to the string representation, and otherwise null.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.ActivatableAttribute

Details

Assembly

Windows.Globalization.NumberFormatting.dll