PermilleFormatter 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
格式化和分析每百万米。
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
- 继承
- 属性
- 实现
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 来转换标记。
构造函数
PermilleFormatter() |
创建 PermilleFormatter 对象并将其初始化为默认值。 |
PermilleFormatter(IIterable<String>, String) |
创建由语言列表和地理区域初始化的 PermilleFormatter 对象。 |
属性
FractionDigits |
获取或设置为每米的小数部分显示的最小位数。 |
GeographicRegion |
获取格式化和分析每米值时使用的区域。 |
IntegerDigits |
获取或设置要为每米整数部分显示的最小位数。 |
IsDecimalPointAlwaysDisplayed |
获取或设置是否应始终显示每米的小数点。 |
IsGrouped |
获取或设置是否应对每米数的整数部分进行分组。 |
IsZeroSigned |
获取或设置 -0 的格式是“-0”还是“0”。 |
Languages |
获取格式设置和分析每毫米值时使用的语言标识符的优先级列表。 |
NumberRounder |
获取或设置格式化每米时要使用的当前舍入策略。 |
NumeralSystem |
获取或设置用于格式化和分析每米值的编号系统。 |
ResolvedGeographicRegion |
获取最近用于格式化或分析每米值的地理区域。 |
ResolvedLanguage |
获取最近用于格式化或分析每米值的语言。 |
SignificantDigits |
获取或设置每米格式时当前填充为有效数字。 |
方法
Format(Double) |
返回 Double permillage 的字符串表示形式。 |
Format(Int64) |
返回 Int64 permillage 的字符串表示形式。 |
Format(UInt64) |
返回 UInt64 每米的字符串表示形式。 |
FormatDouble(Double) |
返回 Double permillage 的字符串表示形式。 |
FormatInt(Int64) |
返回 Int64 permillage 的字符串表示形式。 |
FormatUInt(UInt64) |
返回 UInt64 每米的字符串表示形式。 |
ParseDouble(String) |
尝试分析 Double permillage 的字符串表示形式。 |
ParseInt(String) |
尝试分析整数每米数的字符串表示形式。 |
ParseUInt(String) |
尝试分析无符号整数每米数的字符串表示形式。 |