NumberFormatInfo.CurrencyGroupSizes Propiedad

Definición

Obtiene o establece el número de dígitos en cada grupo a la izquierda de la coma decimal en valores de divisa.Gets or sets the number of digits in each group to the left of the decimal in currency values.

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()

Valor de propiedad

Int32[]

Número de dígitos en cada grupo a la izquierda de la coma decimal en valores de divisa.The number of digits in each group to the left of the decimal in currency values. El valor predeterminado de InvariantInfo es una matriz unidimensional con un único elemento, que se establece en 3.The default for InvariantInfo is a one-dimensional array with only one element, which is set to 3.

Excepciones

La propiedad se establece en null.The property is being set to null.

La propiedad se establece y la matriz contiene una entrada que es menor que 0 o mayor que 9.The property is being set and the array contains an entry that is less than 0 or greater than 9.

O bien-or-

La propiedad se establece y la matriz contiene una entrada distinta a la última entrada que se establece en 0.The property is being set and the array contains an entry, other than the last entry, that is set to 0.

La propiedad está establecida y el objeto NumberFormatInfo es de solo lectura.The property is being set and the NumberFormatInfo object is read-only.

Ejemplos

En el ejemplo siguiente se muestra el efecto del CurrencyGroupSizes cambio de la propiedad.The following example demonstrates the effect of changing the CurrencyGroupSizes property.

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


Comentarios

La CurrencyGroupSizes propiedad se usa con la cadena de formato estándar "C" para definir el número de dígitos que aparecen en los grupos enteros.The CurrencyGroupSizes property is used with the "C" standard format string to define the number of digits that appear in integral groups. Para más información, vea Cadenas de formato numérico estándar.For more information, see Standard Numeric Format Strings. Cada elemento de la matriz unidimensional debe ser un entero comprendido entre 1 y 9.Every element in the one-dimensional array must be an integer from 1 through 9. El último elemento puede ser 0.The last element can be 0.

El primer elemento de la matriz define el número de elementos en el grupo de dígitos menos significativo inmediatamente a la izquierda de CurrencyDecimalSeparator.The first element of the array defines the number of elements in the least significant group of digits immediately to the left of the CurrencyDecimalSeparator. Cada elemento subsiguiente hace referencia al siguiente grupo significativo de dígitos a la izquierda del grupo anterior.Each subsequent element refers to the next significant group of digits to the left of the previous group. Si el último elemento de la matriz no es 0, los dígitos restantes se agrupan en función del último elemento de la matriz.If the last element of the array is not 0, the remaining digits are grouped based on the last element of the array. Si el último elemento es 0, los dígitos restantes no se agrupan.If the last element is 0, the remaining digits are not grouped.

Por ejemplo, si la matriz contiene {3, 4, 5}, los dígitos se agrupan de forma similar a "$ 55, 55555, 55555, 55555, 4444, 333.00".For example, if the array contains { 3, 4, 5 }, the digits are grouped similar to "$55,55555,55555,55555,4444,333.00". Si la matriz contiene {3, 4, 0}, los dígitos se agrupan de forma similar a "$ 55555555555555555, 4444, 333.00".If the array contains { 3, 4, 0 }, the digits are grouped similar to "$55555555555555555,4444,333.00".

Se aplica a

Consulte también: