Mono Class Library: System.Globalization.NumberFormatInfo Overview | Members

System.Globalization.NumberFormatInfo.NumberGroupSizes Property

Gets or sets the number of digits in each group to the left of the decimal point for numeric values. [Edit]

public int[] NumberGroupSizes { set; get; }

Value

A int array containing elements that define the number of digits in each group in numeric values. [Edit]

Exceptions

TypeReason
ArgumentNullExceptionThe array specified for a set operation is a null reference. [Edit]
ArgumentOutOfRangeExceptionOne of the elements in the array specified for a set operation is not between 0 and 9. [Edit]
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted. [Edit]

Remarks

All elements of the array except the last are required to be between 1 and 9, inclusive. The last element can be 0.

The first element of the array defines the number of elements in the first group of digits located immediately to the left of the NumberFormatInfo.NumberDecimalSeparator. Each subsequent element refers to the next group of digits located to the left of the previous group. If the last element of the array is not zero, any remaining digits are grouped based on the last element of the array. If the last element is zero, the remaining digits are not grouped.

The culture-invariant value for this property is an array with a single element containing the value 3.

[Edit]

Example

The following example demonstrates the effects of different NumberFormatInfo.NumberGroupSizes property values.

C# Example
using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 
 decimal data = 9999999994444333221.00m;
 nfi.NumberGroupSizes = new int[] {1,2,3,4,0};
 Console.WriteLine("{0}",data.ToString("N",nfi));

 data = 123456789123456.78m;
 nfi.NumberGroupSizes = new int[] {3};
 Console.WriteLine("{0}",data.ToString("N",nfi));

 nfi.NumberGroupSizes = new int[] {3,0};
 Console.WriteLine("{0}",data.ToString("N",nfi));
 }
}
   

The output is

999999999,4444,333,22,1.00
123,456,789,123,456.78
123456789123,456.78

Requirements

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0