NumberFormatInfo.CurrencyGroupSizes 속성

정의

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

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

속성 값

Int32[]

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

예외

속성이 null로 설정되어 있습니다.

속성이 설정되거나 배열에 0보다 작거나 9보다 큰 항목이 포함되어 있습니다.

또는

속성이 설정되거나 배열의 마지막 항목 이외의 항목이 0으로 설정되어 있습니다.

속성이 설정되어 있으며 NumberFormatInfo 개체가 읽기 전용입니다.

예제

다음 예제에서는 변경의 효과 보여 줍니다.는 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

설명

CurrencyGroupSizes 속성은 정수 계열 그룹에 나타나는 자릿수를 정의 하려면 "C" 표준 서식 문자열과 함께 사용 합니다. 자세한 내용은 표준 숫자 형식 문자열을 참조하세요. 1 차원 배열의 모든 요소에는 1에서 9 사이의 정수 여야 합니다. 마지막 요소에는 0 일 수 있습니다.

자릿수의 왼쪽에 바로 가장 중요 하지 않은 그룹의 요소 수를 정의 하는 배열의 첫 번째 요소는 CurrencyDecimalSeparator합니다. 각 후속 요소에서 이전 그룹의 왼쪽으로 자릿수 다음 중요 한 그룹을 가리킵니다. 배열의 마지막 요소 다음 위치에 있는 경우 0이 아닌 나머지 숫자는 기준으로 그룹화 배열의 마지막 요소입니다. 마지막 요소의 0 인 경우에 나머지 자릿수 그룹화 되지 않습니다.

예를 들어, 배열 {3, 4, 5}를 포함 하는 경우 숫자 "$55,55555,55555,55555,4444,333.00" 비슷합니다 그룹화 됩니다. 배열 {3, 4, 0}에 숫자를 "$55555555555555555,4444,333.00" 비슷합니다 그룹화 됩니다.

적용 대상

추가 정보