PermilleFormatter PermilleFormatter PermilleFormatter PermilleFormatter Class

Formats and parses permillages.

Syntax

Declaration

public sealed class PermilleFormatterpublic sealed class PermilleFormatterPublic NotInheritable Class PermilleFormatterpublic sealed class PermilleFormatter

Remarks

Note

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.

Examples

// This scenario uses the Windows.Globalization.NumberFormatting.PercentFormatter and
// the Windows.Globalization.NumberFormatting.PermilleFormatter classes to format numbers
// as a percent or a permille.

// Create formatters initialized using the current user's preference settings.
var percentFormat = new Windows.Globalization.NumberFormatting.PercentFormatter();
var permilleFormat = new Windows.Globalization.NumberFormatting.PermilleFormatter();

// Make a random number.
var randomNumber = Math.random();

// Format with current user preferences.
var percent = percentFormat.format(randomNumber);
var permille = permilleFormat.format(randomNumber);

// Get a fixed number.
var fixedNumber = 500;

// Format with grouping using default.
var percentFormat1 = new Windows.Globalization.NumberFormatting.PercentFormatter();
percentFormat1.isGrouped = true;
var percent1 = percentFormat1.format(fixedNumber);

// Format with grouping using French.
var percentFormatFR = new Windows.Globalization.NumberFormatting.PercentFormatter(["fr-FR"], "FR");
percentFormatFR.isGrouped = true;
var percentFR = percentFormatFR.format(fixedNumber);

// Format with no fractional digits using default.
var percentFormat2 = new Windows.Globalization.NumberFormatting.PercentFormatter();
percentFormat2.fractionDigits = 0;
var percent2 = percentFormat2.format(fixedNumber);

// Format always with a decimal point.
var percentFormat3 = new Windows.Globalization.NumberFormatting.PercentFormatter();
percentFormat3.isDecimalPointAlwaysDisplayed = true;
percentFormat3.fractionDigits = 0;
var percent3 = percentFormat3.format(fixedNumber);

// Display the results.
var results = "Random number (" + randomNumber + ")\n" +
              "Percent formatted: " + percent + "\n" +
              "Permille formatted: " + permille + "\n\n" +
              "Fixed number (" + fixedNumber + ")\n" +
              "Percent formatted (grouped): " + percent1 + "\n" +
              "Percent formatted (grouped as fr-FR): " + percentFR + "\n" +
              "Percent formatted (no fractional digits): " + percent2 + "\n" +
              "Percent formatted (always with a decimal point): " + percent3;
// This scenario uses the Windows.Globalization.NumberFormatting.PercentFormatter and
// the Windows.Globalization.NumberFormatting.PermilleFormatter classes to format numbers
// as a percent or a permille.

//using System.Text;
//using Windows.Globalization.NumberFormatting;

StringBuilder sb = new StringBuilder();

// Create numbers to format.
double randomNumber = new Random().NextDouble();
ulong fixedNumber = 500;

// Create percent formatters.
PercentFormatter defaultPercentFormatter = new PercentFormatter();
PercentFormatter languagePercentFormatter = new PercentFormatter(new[] { "fr-FR" }, "ZZ");

// Create permille formatters.
PermilleFormatter defaultPermilleFormatter = new PermilleFormatter();
PermilleFormatter languagePermilleFormatter = new PermilleFormatter(new[] { "ar" }, "ZZ");

// Format random numbers as percent or permille.
sb.AppendLine("Random number: " + randomNumber);
sb.AppendLine("Percent formatted: " + defaultPercentFormatter.Format(randomNumber));
sb.AppendLine("Permille formatted: " + defaultPermilleFormatter.Format(randomNumber));
sb.AppendLine();
sb.AppendLine("Language-specific percent formatted: " + languagePercentFormatter.Format(randomNumber));
sb.AppendLine("Language-specific permille formatted: " + languagePermilleFormatter.Format(randomNumber));
sb.AppendLine();
sb.AppendLine("Fixed number: " + fixedNumber);

// Format fixed number with grouping.
defaultPercentFormatter.IsGrouped = true;
sb.AppendLine("Percent formatted (grouped): " + defaultPercentFormatter.Format(fixedNumber));

//Format with grouping using French language.
languagePercentFormatter.IsGrouped = true;
sb.AppendLine("Percent formatted (grouped as fr-FR): " + defaultPercentFormatter.Format(fixedNumber));

// Format with no fraction digits.
defaultPercentFormatter.FractionDigits = 0;
sb.AppendLine("Percent formatted (no fractional digits): " + defaultPercentFormatter.Format(fixedNumber));

// Format always with a decimal point.
defaultPercentFormatter.IsDecimalPointAlwaysDisplayed = true;
sb.AppendLine("Percent formatted (always with a decimal point): " + defaultPercentFormatter.Format(fixedNumber));

Constructors summary

Creates a PermilleFormatter object and initializes it to default values.

Creates a PermilleFormatter object initialized by a language list and a geographic region.

Properties summary

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

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

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

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

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

Gets or sets whether -0 is formatted as "-0" or "0".

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

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

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

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

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

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

Methods summary

Returns a string representation of a Double permillage.

Returns a string representation of an Int64 permillage.

Returns a string representation of a UInt64 permillage.

Returns a string representation of a Double permillage.

Returns a string representation of an Int64 permillage.

Returns a string representation of a UInt64 permillage.

Attempts to parse a string representation of a Double permillage.

Attempts to parse a string representation of an integer permillage.

Attempts to parse a string representation of an unsigned integer permillage.

Constructors

  • PermilleFormatter()
    PermilleFormatter()
    PermilleFormatter()
    PermilleFormatter()

    Creates a PermilleFormatter object and initializes it to default values.

    public PermilleFormatter()public New()Public Sub New()public PermilleFormatter()
  • PermilleFormatter(IIterable<String>, String)
    PermilleFormatter(IIterable<String>, String)
    PermilleFormatter(IIterable<String>, String)
    PermilleFormatter(IIterable<String>, String)

    Creates a PermilleFormatter object initialized by a language list and a geographic region.

    public PermilleFormatter(IIterable<String> languages, String geographicRegion)public New(IIterable<String> languages, String geographicRegion)Public Sub New(languages As IIterable<String>, geographicRegion As String)public PermilleFormatter(IIterable<String> languages, String geographicRegion)

    Parameters

    • 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

    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 PermilleFormatter objects.

Properties

  • FractionDigits
    FractionDigits
    FractionDigits
    FractionDigits

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

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

    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 permille values.

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

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

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

    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 permillage should always be displayed.

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

    Property Value

    • bool
      bool
      bool
      bool

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

  • IsGrouped
    IsGrouped
    IsGrouped
    IsGrouped

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

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

    Property Value

    • bool
      bool
      bool
      bool

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

  • IsZeroSigned
    IsZeroSigned
    IsZeroSigned
    IsZeroSigned

    Gets or sets whether -0 is formatted as "-0" or "0".

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

    Property Value

    • bool
      bool
      bool
      bool

      True if -0 is formatted as "-0", and false if -0 is formatted as "0".

    Remarks

    You can set this property to specify that PermilleFormatter 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 permille values.

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

    Property Value

    • The priority list of language identifiers.

      Starting in : Language tags can support Unicode extensions. See the Remarks for the @Windows.Globalization.NumberFormatting.PermilleFormatter.#ctor(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.

  • NumberRounder
    NumberRounder
    NumberRounder
    NumberRounder

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

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

    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 permille values.

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

    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.

    Remarks

    Note

    For Arabic numeral systems ("Arab" and "ArabExt" or any numeral systems which use a combination of those characters):+ A period (.) immediately before a Latin digit is converted to the Arabic Decimal Separator (u+66b).

    • A comma (,) immediately before a Latin digit is converted to Arabic Thousand Separator (u+66c).
    • A percent (%) adjacent to a Latin digit is converted to Arabic Per Cent Symbol (u+66a).
    • A permille (u+2030) adjacent to a Latin digit is converted to Arabic Per Mille Symbol (u+609).
  • ResolvedGeographicRegion
    ResolvedGeographicRegion
    ResolvedGeographicRegion
    ResolvedGeographicRegion

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

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

    Property Value

    • string
      string
      string
      string

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

  • ResolvedLanguage
    ResolvedLanguage
    ResolvedLanguage
    ResolvedLanguage

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

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

    Property Value

    • string
      string
      string
      string

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

      Starting in : Language tags can support Unicode extensions. See the Remarks for the @Windows.Globalization.NumberFormatting.PermilleFormatter.#ctor(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 permille is formatted.

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

    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

  • Format(Double)
    Format(Double)
    Format(Double)
    Format(Double)

    Returns a string representation of a Double permillage.

    public string Format(Double value)public string Format(Double value)Public Function Format(value As Double) As stringpublic string Format(Double value)

    Parameters

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

      The Double value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the permillage.

  • Format(Int64)
    Format(Int64)
    Format(Int64)
    Format(Int64)

    Returns a string representation of an Int64 permillage.

    public string Format(Int64 value)public string Format(Int64 value)Public Function Format(value As Int64) As stringpublic string Format(Int64 value)

    Parameters

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

      The Int64 value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the permillage.

  • Format(UInt64)
    Format(UInt64)
    Format(UInt64)
    Format(UInt64)

    Returns a string representation of a UInt64 permillage.

    public string Format(UInt64 value)public string Format(UInt64 value)Public Function Format(value As UInt64) As stringpublic string Format(UInt64 value)

    Parameters

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

      The UInt64 value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the permillage.

  • FormatDouble(Double)
    FormatDouble(Double)
    FormatDouble(Double)
    FormatDouble(Double)

    Returns a string representation of a Double permillage.

    public string FormatDouble(Double value)public string FormatDouble(Double value)Public Function FormatDouble(value As Double) As stringpublic string FormatDouble(Double value)

    Parameters

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

      The Double value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the permillage.

  • FormatInt(Int64)
    FormatInt(Int64)
    FormatInt(Int64)
    FormatInt(Int64)

    Returns a string representation of an Int64 permillage.

    public string FormatInt(Int64 value)public string FormatInt(Int64 value)Public Function FormatInt(value As Int64) As stringpublic string FormatInt(Int64 value)

    Parameters

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

      The Int64 value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the permillage.

  • FormatUInt(UInt64)
    FormatUInt(UInt64)
    FormatUInt(UInt64)
    FormatUInt(UInt64)

    Returns a string representation of a UInt64 permillage.

    public string FormatUInt(UInt64 value)public string FormatUInt(UInt64 value)Public Function FormatUInt(value As UInt64) As stringpublic string FormatUInt(UInt64 value)

    Parameters

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

      The UInt64 value to be formatted.

    Returns

    • string
      string
      string
      string

      A string that represents the permillage.

  • ParseDouble(String)
    ParseDouble(String)
    ParseDouble(String)
    ParseDouble(String)

    Attempts to parse a string representation of a Double permillage.

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

    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(String)
    ParseInt(String)
    ParseInt(String)
    ParseInt(String)

    Attempts to parse a string representation of an integer permillage.

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

    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(String)
    ParseUInt(String)
    ParseUInt(String)
    ParseUInt(String)

    Attempts to parse a string representation of an unsigned integer permillage.

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

    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.ActivatableAttribute
Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Globalization.NumberFormatting.dll