NumberFormatInfo.CurrencyGroupSizes Özellik

Tanım

Para birimi değerlerindeki ondalık değerin solundaki her gruptaki basamak sayısını alır veya ayarlar.

public:
 property cli::array <int> ^ CurrencyGroupSizes { cli::array <int> ^ get(); void set(cli::array <int> ^ value); };
public int[] CurrencyGroupSizes { get; set; }
member this.CurrencyGroupSizes : int[] with get, set
Public Property CurrencyGroupSizes As Integer()

Özellik Değeri

Int32[]

Para birimi değerlerinde ondalık değerin solundaki her gruptaki basamak sayısı. için InvariantInfo varsayılan değer, 3 olarak ayarlanmış tek bir öğeye sahip tek boyutlu bir dizidir.

Özel durumlar

özelliği olarak nullayarlanıyor.

özelliği ayarlanıyor ve dizi 0'dan küçük veya 9'dan büyük bir girdi içeriyor.

-veya-

özelliği ayarlanıyor ve dizi, son girdi dışında 0 olarak ayarlanmış bir girdi içeriyor.

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

Örnekler

Aşağıdaki örnekte özelliği değiştirmenin etkisi gösterilmektedir CurrencyGroupSizes .

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 value with the default separator (S".").
   Int64 myInt = 123456789012345;
   Console::WriteLine( myInt.ToString( "C", nfi ) );
   
   // Displays the same value with different groupings.
   array<Int32>^mySizes1 = {2,3,4};
   array<Int32>^mySizes2 = {2,3,0};
   nfi->CurrencyGroupSizes = mySizes1;
   Console::WriteLine( myInt.ToString( "C", nfi ) );
   nfi->CurrencyGroupSizes = mySizes2;
   Console::WriteLine( myInt.ToString( "C", nfi ) );
}

/* 
This code produces the following output.

$123, 456, 789, 012, 345.00
$12, 3456, 7890, 123, 45.00
$1234567890, 123, 45.00
*/
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 value with the default separator (".").
      Int64 myInt = 123456789012345;
      Console.WriteLine( myInt.ToString( "C", nfi ) );

      // Displays the same value with different groupings.
      int[] mySizes1 = {2,3,4};
      int[] mySizes2 = {2,3,0};
      nfi.CurrencyGroupSizes = mySizes1;
      Console.WriteLine( myInt.ToString( "C", nfi ) );
      nfi.CurrencyGroupSizes = mySizes2;
      Console.WriteLine( myInt.ToString( "C", nfi ) );
   }
}


/*
This code produces the following output.

$123,456,789,012,345.00
$12,3456,7890,123,45.00
$1234567890,123,45.00
*/
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 value with the default separator (".").
      Dim myInt As Int64 = 123456789012345
      Console.WriteLine(myInt.ToString("C", nfi))

      ' Displays the same value with different groupings.
      Dim mySizes1 As Integer() =  {2, 3, 4}
      Dim mySizes2 As Integer() =  {2, 3, 0}
      nfi.CurrencyGroupSizes = mySizes1
      Console.WriteLine(myInt.ToString("C", nfi))
      nfi.CurrencyGroupSizes = mySizes2
      Console.WriteLine(myInt.ToString("C", nfi))

   End Sub

End Class

 
'This code produces the following output.
'
'$123,456,789,012,345.00
'$12,3456,7890,123,45.00
'$1234567890,123,45.00

Açıklamalar

CurrencyGroupSizes özelliği, tam sayı gruplarında görünen basamak sayısını tanımlamak için "C" standart biçim dizesiyle birlikte kullanılır. Daha fazla bilgi için bkz. Standart Sayısal Biçim Dizeleri. Tek boyutlu dizideki her öğe 1 ile 9 arasında bir tamsayı olmalıdır. Son öğe 0 olabilir.

Dizinin ilk öğesi, öğesinin hemen solundaki CurrencyDecimalSeparatoren az önemli basamak grubundaki öğe sayısını tanımlar. Sonraki her öğe, önceki grubun solundaki bir sonraki önemli basamak grubuna başvurur. Dizinin son öğesi 0 değilse, kalan basamaklar dizinin son öğesine göre gruplandırılır. Son öğe 0 ise, kalan basamaklar gruplandırılmaz.

Örneğin, dizi { 3, 4, 5 } içeriyorsa basamaklar "$55,55555,5555,55555,4444,333,00" gibi gruplandırılır. Dizi { 3, 4, 0 } içeriyorsa, basamaklar "$55555555555555555555,4444,333,00" gibi gruplandırılır.

Şunlara uygulanır

Ayrıca bkz.