PercentFormatter Classe

Définition

Met en forme et analyse les pourcentages.

public ref class PercentFormatter sealed : INumberFormatter, INumberFormatter2, INumberFormatterOptions, INumberParser, INumberRounderOption, ISignedZeroOption, ISignificantDigitsOption
/// [Windows.Foundation.Metadata.Activatable(65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.NumberFormatting.IPercentFormatterFactory, 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 PercentFormatter 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(65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(Windows.Globalization.NumberFormatting.IPercentFormatterFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class PercentFormatter 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.IPercentFormatterFactory), 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 PercentFormatter : 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(65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Globalization.NumberFormatting.IPercentFormatterFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class PercentFormatter : INumberFormatter, INumberFormatter2, INumberFormatterOptions, INumberParser, INumberRounderOption, ISignedZeroOption, ISignificantDigitsOption
function PercentFormatter(languages, geographicRegion)
Public NotInheritable Class PercentFormatter
Implements INumberFormatter, INumberFormatter2, INumberFormatterOptions, INumberParser, INumberRounderOption, ISignedZeroOption, ISignificantDigitsOption
Héritage
Object Platform::Object IInspectable PercentFormatter
Attributs
Implémente

Configuration requise pour Windows

Famille d’appareils
Windows 10 (introduit dans 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduit dans v1.0)

Exemples

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

Remarques

Notes

Si votre application transmet les balises de langue utilisées dans cette classe à n’importe quelle fonction de prise en charge des langues nationales , elle doit d’abord convertir les balises en appelant ResolveLocaleName.

Constructeurs

PercentFormatter()

Crée un objet PercentFormatter et l’initialise avec les valeurs par défaut.

PercentFormatter(IIterable<String>, String)

Crée un objet PercentFormatter initialisé par une liste de langues et une région géographique.

Propriétés

FractionDigits

Obtient ou définit le nombre minimal de chiffres à afficher pour la partie fraction du pourcentage.

GeographicRegion

Obtient la région utilisée lors de la mise en forme et de l’analyse des pourcentages.

IntegerDigits

Obtient ou définit le nombre minimal de chiffres à afficher pour la partie entière du pourcentage.

IsDecimalPointAlwaysDisplayed

Obtient ou définit si la virgule décimale du pourcentage doit toujours être affichée.

IsGrouped

Obtient ou définit si la partie entière du pourcentage doit être regroupée.

IsZeroSigned

Obtient ou définit si -0 est mis en forme comme « -0 » ou « 0 ».

Languages

Obtient la liste de priorité des identificateurs de langue utilisés lors de la mise en forme et de l’analyse des pourcentages.

NumberRounder

Obtient ou définit la stratégie d’arrondi actuelle à utiliser lors de la mise en forme des pourcentages.

NumeralSystem

Obtient ou définit le système de numérotation utilisé pour mettre en forme et analyser les pourcentages.

ResolvedGeographicRegion

Obtient la région géographique qui a été utilisée le plus récemment pour mettre en forme ou analyser des valeurs de pourcentage.

ResolvedLanguage

Obtient la langue qui a été utilisée le plus récemment pour mettre en forme ou analyser des valeurs en pourcentage.

SignificantDigits

Obtient ou définit le remplissage actuel sur des chiffres significatifs lorsqu’un pourcentage est mis en forme.

Méthodes

Format(Double)

Retourne une représentation sous forme de chaîne d’un pourcentage double .

Format(Int64)

Retourne une représentation sous forme de chaîne d’un pourcentage Int64 .

Format(UInt64)

Retourne une représentation sous forme de chaîne d’un pourcentage UInt64 .

FormatDouble(Double)

Retourne une représentation sous forme de chaîne d’un pourcentage double .

FormatInt(Int64)

Retourne une représentation sous forme de chaîne d’un pourcentage Int64 .

FormatUInt(UInt64)

Retourne une représentation sous forme de chaîne d’un pourcentage UInt64 .

ParseDouble(String)

Tente d’analyser une représentation sous forme de chaîne d’un pourcentage double .

ParseInt(String)

Tente d’analyser une représentation sous forme de chaîne d’un pourcentage entier.

ParseUInt(String)

Tente d’analyser une représentation sous forme de chaîne d’un pourcentage entier non signé.

S’applique à

Voir aussi