NumberFormatInfo.PercentDecimalDigits Özellik

Tanım

Yüzde değerlerinde kullanılacak ondalık basamak sayısını alır veya ayarlar.

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

Özellik Değeri

Yüzde değerlerinde kullanılacak ondalık basamak sayısı. için InvariantInfo varsayılan değer 2'dir.

Özel durumlar

özelliği 0'dan küçük veya 99'dan büyük bir değere ayarlanıyor.

özelliği ayarlanıyor ve NumberFormatInfo nesne salt okunur.

Örnekler

Aşağıdaki örnekte özelliği değiştirmenin etkisi gösterilmektedir 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 %

Açıklamalar

PercentDecimalDigits özelliği, sayısal biçimlendirme işlemlerinde duyarlık belirticisi olmayan "P" standart biçim dizesiyle kullanılır. Ondalık ayırıcıdan sonra görünen varsayılan kesirli basamak sayısını tanımlar. Duyarlık belirtici kullanılırsa bu değer geçersiz kılınmış olur. Daha fazla bilgi için bkz. Standart Sayısal Biçim Dizeleri.

Şunlara uygulanır

Ayrıca bkz.