PercentFormatter クラス

定義

パーセンテージを書式設定して解析します。

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
継承
Object Platform::Object IInspectable PercentFormatter
属性
実装

Windows の要件

デバイス ファミリ
Windows 10 (10.0.10240.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v1.0 で導入)

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

注釈

注意

アプリがこのクラスで使用されている言語タグを 各国語サポート 関数に渡す場合は、最初に ResolveLocaleName を呼び出してタグを変換する必要があります。

コンストラクター

PercentFormatter()

PercentFormatter オブジェクトを作成し、既定値に初期化します。

PercentFormatter(IIterable<String>, String)

言語リストと地理的リージョンによって初期化された PercentFormatter オブジェクトを作成します。

プロパティ

FractionDigits

パーセンテージの分数部分に表示する最小桁数を取得または設定します。

GeographicRegion

パーセンテージの書式設定と解析時に使用される領域を取得します。

IntegerDigits

パーセンテージの整数部分に表示する最小桁数を取得または設定します。

IsDecimalPointAlwaysDisplayed

パーセンテージの小数点を常に表示するかどうかを取得または設定します。

IsGrouped

パーセンテージの整数部分をグループ化するかどうかを取得または設定します。

IsZeroSigned

-0 を "-0" または "0" として書式設定するかどうかを取得または設定します。

Languages

パーセンテージの書式設定と解析時に使用される言語識別子の優先順位リストを取得します。

NumberRounder

パーセントを書式設定するときに使用する現在の丸め方法を取得または設定します。

NumeralSystem

パーセンテージの書式設定と解析に使用される番号付けシステムを取得または設定します。

ResolvedGeographicRegion

パーセント値の書式設定または解析に最後に使用された地理的リージョンを取得します。

ResolvedLanguage

パーセント値の書式設定または解析に最後に使用された言語を取得します。

SignificantDigits

パーセントが書式設定されている場合に、現在の埋め込みを有効桁数に設定します。

メソッド

Format(Double)

倍精度浮動小数点型 ( Double ) の割合を表す文字列を返します。

Format(Int64)

Int64 パーセントの文字列表現を返します。

Format(UInt64)

UInt64 パーセントの文字列表現を返します。

FormatDouble(Double)

倍精度浮動小数点型 ( Double ) の割合を表す文字列を返します。

FormatInt(Int64)

Int64 パーセントの文字列表現を返します。

FormatUInt(UInt64)

UInt64 パーセントの文字列表現を返します。

ParseDouble(String)

倍精度浮動小数点型 ( Double ) の割合の文字列表現の解析を試みます。

ParseInt(String)

整数の割合の文字列表現を解析しようとします。

ParseUInt(String)

符号なし整数パーセンテージの文字列表現の解析を試みます。

適用対象

こちらもご覧ください