다음을 통해 공유


NumberFormatInfo.PercentGroupSizes 속성

백분율 값에서 정수 부분의 각 그룹 자릿수를 가져오거나 설정합니다.

네임스페이스: System.Globalization
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Property PercentGroupSizes As Integer()
‘사용 방법
Dim instance As NumberFormatInfo
Dim value As Integer()

value = instance.PercentGroupSizes

instance.PercentGroupSizes = value
public int[] PercentGroupSizes { get; set; }
public:
property array<int>^ PercentGroupSizes {
    array<int>^ get ();
    void set (array<int>^ value);
}
/** @property */
public int[] get_PercentGroupSizes ()

/** @property */
public void set_PercentGroupSizes (int[] value)
public function get PercentGroupSizes () : int[]

public function set PercentGroupSizes (value : int[])

속성 값

백분율 값에서 정수 부분의 각 그룹 자릿수입니다. InvariantInfo 기본값은 3으로 설정된 하나의 요소만 있는 1차원 배열입니다.

예외

예외 형식 조건

ArgumentNullException

속성이 Null 참조(Visual Basic의 경우 Nothing)로 설정되는 경우

ArgumentException

속성을 설정하고 배열에 0보다 작거나 9보다 큰 항목이 들어 있는 경우

- 또는 -

속성을 설정하고 배열에 마지막 항목이 아닌 0으로 설정된 항목이 있는 경우

InvalidOperationException

속성이 설정되어 있으며 NumberFormatInfo는 읽기 전용인 경우

설명

1차원 배열의 모든 요소는 1부터 9까지의 정수여야 합니다. 마지막 요소는 0일 수 있습니다.

배열의 첫째 요소가 PercentDecimalSeparator로 구분되는 최하위 그룹 자릿수를 정의합니다. 다음에 나오는 각 요소는 이전 그룹의 왼쪽에 있는 다음 유효 그룹 자릿수를 나타냅니다. 배열의 마지막 요소가 0이 아닌 경우 나머지 자릿수는 배열의 마지막 요소에 따라 그룹화됩니다. 마지막 요소가 0인 경우 나머지 자릿수는 그룹화되지 않습니다.

예를 들어, 배열에 { 3, 4, 5 }가 들어 있는 경우 자릿수는 "55,55555,55555,55555,4444,333.00%"처럼 그룹화됩니다. 배열에 { 3, 4, 0 }이 들어 있으면 자릿수는 "55555555555555555,4444,333.00%"처럼 그룹화됩니다.

예제

다음 코드 예제에서는 PercentGroupSizes 속성의 변경 내용이 적용된 결과를 보여 줍니다.

Imports System
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 [Double] = 123456789012345.6789
      Console.WriteLine(myInt.ToString("P", nfi))

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

   End Sub 'Main 

End Class 'NumberFormatInfoSample


'This code produces the following output.

'

'12,345,678,901,234,600.00 %

'1234,5678,9012,346,00.00 %

'123456789012,346,00.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 (".").
      Double myInt = 123456789012345.6789;
      Console.WriteLine( myInt.ToString( "P", nfi ) );

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

   }
}


/* 
This code produces the following output.

12,345,678,901,234,600.00 %
1234,5678,9012,346,00.00 %
123456789012,346,00.00 %
*/
   
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".").
   Double myInt = 123456789012345.6789;
   Console::WriteLine( myInt.ToString( "P", nfi ) );
   
   // Displays the same value with different groupings.
   array<Int32>^mySizes1 = {2,3,4};
   array<Int32>^mySizes2 = {2,3,0};
   nfi->PercentGroupSizes = mySizes1;
   Console::WriteLine( myInt.ToString( "P", nfi ) );
   nfi->PercentGroupSizes = mySizes2;
   Console::WriteLine( myInt.ToString( "P", nfi ) );
}

/*
This code produces the following output.

12, 345, 678, 901, 234, 600.00 %
1234, 5678, 9012, 346, 00.00 %
123456789012, 346, 00.00 %
*/
import System.*;
import System.Globalization.*;

class NumberFormatInfoSample
{
    public static void main(String[] args)
    {
        // Gets a NumberFormatInfo associated with the en-US culture.
        NumberFormatInfo nfi = (new CultureInfo("en-US", false)).
            get_NumberFormat();
        // Displays a value with the default separator (".").
        System.Double myInt = (System.Double)123456789012346L;
        Console.WriteLine(myInt.ToString("P", nfi));
        // Displays the same value with different groupings.
        int mySizes1[] =  { 2, 3, 4 };
        int mySizes2[] =  { 2, 3, 0 };
        nfi.set_PercentGroupSizes(mySizes1);
        Console.WriteLine(myInt.ToString("P", nfi));
        nfi.set_PercentGroupSizes(mySizes2);
        Console.WriteLine(myInt.ToString("P", nfi));
    } //main 
} //NumberFormatInfoSample

/* 
This code produces the following output.

12,345,678,901,234,600.00 %
1234,5678,9012,346,00.00 %
123456789012,346,00.00 %
*/

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

NumberFormatInfo 클래스
NumberFormatInfo 멤버
System.Globalization 네임스페이스
NumberFormatInfo.PercentDecimalDigits 속성
NumberFormatInfo.PercentDecimalSeparator 속성
NumberFormatInfo.PercentGroupSeparator 속성
PercentSymbol
PercentNegativePattern
PercentPositivePattern
NumberFormatInfo.CurrencyGroupSizes 속성
NumberFormatInfo.NumberGroupSizes 속성