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)

이중 백분율의 문자열 표현을 구문 분석하려고 시도합니다.

ParseInt(String)

정수 백분율의 문자열 표현을 구문 분석하려고 시도합니다.

ParseUInt(String)

부호 없는 정수 백분율의 문자열 표현을 구문 분석하려고 시도합니다.

적용 대상

추가 정보