NumberFormatInfo.PercentDecimalDigits 속성

정의

백분율 값에 사용할 소수 자릿수를 가져오거나 설정합니다.

public:
 property int PercentDecimalDigits { int get(); void set(int value); };
public int PercentDecimalDigits { get; set; }
member this.PercentDecimalDigits : int with get, set
Public Property PercentDecimalDigits As Integer

속성 값

백분율 값에 사용할 소수 자릿수입니다. InvariantInfo의 기본값은 2입니다.

예외

속성이 0보다 작거나 99보다 큰 값으로 설정됩니다.

속성이 설정되어 있으며 NumberFormatInfo 개체가 읽기 전용입니다.

예제

다음 예제에서는 변경의 효과 보여 줍니다.는 PercentDecimalDigits 속성입니다.

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Gets a NumberFormatInfo associated with the en-US culture.
   CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false );
   NumberFormatInfo^ nfi = MyCI->NumberFormat;
   
   // Displays a negative value with the default number of decimal digits (2).
   Double myInt = 0.1234;
   Console::WriteLine( myInt.ToString( "P", nfi ) );
   
   // Displays the same value with four decimal digits.
   nfi->PercentDecimalDigits = 4;
   Console::WriteLine( myInt.ToString( "P", nfi ) );
}

/*
This code produces the following output.
12.34 %
12.3400 %
*/
using System;
using System.Globalization;

class NumberFormatInfoSample {

   public static void Main() {

      // Gets a NumberFormatInfo associated with the en-US culture.
      NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat;

      // Displays a negative value with the default number of decimal digits (2).
      Double myInt = 0.1234;
      Console.WriteLine( myInt.ToString( "P", nfi ) );

      // Displays the same value with four decimal digits.
      nfi.PercentDecimalDigits = 4;
      Console.WriteLine( myInt.ToString( "P", nfi ) );
   }
}


/*
This code produces the following output.

12.34 %
12.3400 %
*/
Imports System.Globalization

Class NumberFormatInfoSample

   Public Shared Sub Main()

      ' Gets a NumberFormatInfo associated with the en-US culture.
      Dim nfi As NumberFormatInfo = New CultureInfo("en-US", False).NumberFormat

      ' Displays a negative value with the default number of decimal digits (2).
      Dim myInt As [Double] = 0.1234
      Console.WriteLine(myInt.ToString("P", nfi))

      ' Displays the same value with four decimal digits.
      nfi.PercentDecimalDigits = 4
      Console.WriteLine(myInt.ToString("P", nfi))

   End Sub

End Class


'This code produces the following output.
'
'12.34 %
'12.3400 %

설명

PercentDecimalDigits 속성은 숫자 서식 지정 작업의에서 전체 자릿수 지정자 없이 "P" 표준 서식 문자열을 사용 하 여 사용 합니다. 소수 구분 기호 다음에 표시 되는 소수 자릿수의 기본값을 정의 합니다. 전체 자릿수 지정자를 사용 하는 경우이 값이 재정의 됩니다. 자세한 내용은 표준 숫자 형식 문자열을 참조하세요.

적용 대상

추가 정보