Share via


PermilleFormatter Class

Definition

Formats and parses permillages.

public ref class PermilleFormatter sealed : INumberFormatter, INumberFormatter2, INumberFormatterOptions, INumberParser, INumberRounderOption, ISignedZeroOption, ISignificantDigitsOption
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.NumberFormatting.IPermilleFormatterFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class PermilleFormatter final : INumberFormatter, INumberFormatter2, INumberFormatterOptions, INumberParser, INumberRounderOption, ISignedZeroOption, ISignificantDigitsOption
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.NumberFormatting.IPermilleFormatterFactory, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
class PermilleFormatter final : INumberFormatter, INumberFormatter2, INumberFormatterOptions, INumberParser, INumberRounderOption, ISignedZeroOption, ISignificantDigitsOption
[Windows.Foundation.Metadata.Activatable(65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Globalization.NumberFormatting.IPermilleFormatterFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class PermilleFormatter : INumberFormatter, INumberFormatter2, INumberFormatterOptions, INumberParser, INumberRounderOption, ISignedZeroOption, ISignificantDigitsOption
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Globalization.NumberFormatting.IPermilleFormatterFactory), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(65536, "Windows.Foundation.UniversalApiContract")]
public sealed class PermilleFormatter : INumberFormatter, INumberFormatter2, INumberFormatterOptions, INumberParser, INumberRounderOption, ISignedZeroOption, ISignificantDigitsOption
function PermilleFormatter(languages, geographicRegion)
Public NotInheritable Class PermilleFormatter
Implements INumberFormatter, INumberFormatter2, INumberFormatterOptions, INumberParser, INumberRounderOption, ISignedZeroOption, ISignificantDigitsOption
Inheritance
Object Platform::Object IInspectable PermilleFormatter
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

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.

//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));

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.

Constructors

PermilleFormatter()

Creates a PermilleFormatter object and initializes it to default values.

PermilleFormatter(IIterable<String>, String)

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

Properties

FractionDigits

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

GeographicRegion

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

IntegerDigits

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

IsDecimalPointAlwaysDisplayed

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

IsGrouped

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

IsZeroSigned

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

Languages

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

NumberRounder

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

NumeralSystem

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

ResolvedGeographicRegion

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

ResolvedLanguage

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

SignificantDigits

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

Methods

Format(Double)

Returns a string representation of a Double permillage.

Format(Int64)

Returns a string representation of an Int64 permillage.

Format(UInt64)

Returns a string representation of a UInt64 permillage.

FormatDouble(Double)

Returns a string representation of a Double permillage.

FormatInt(Int64)

Returns a string representation of an Int64 permillage.

FormatUInt(UInt64)

Returns a string representation of a UInt64 permillage.

ParseDouble(String)

Attempts to parse a string representation of a Double permillage.

ParseInt(String)

Attempts to parse a string representation of an integer permillage.

ParseUInt(String)

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

Applies to

See also