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

System.Globalization.NumberFormatInfo.PercentGroupSizes Property

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

public int[] PercentGroupSizes { set; get; }

Value

A int array containing elements that define the number of digits in each group in percent 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]
ArgumentException

One of the elements in the array specified for a set operation is not between 0 and 9.

-or-

The array contains an element, other than the last element, that is set to 0.

[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.PercentDecimalSeparator. 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.PercentGroupSizes property values.

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

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

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

The output is

99999999944,4433,322,10,0.00 %
12,345,678,912,345,678.00 %
12345678912345,678.00 %

Requirements

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