다음을 통해 공유


NumberFormatInfo.CurrencyDecimalDigits 속성

통화 값에 사용할 소수 자릿수를 나타냅니다.

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

구문

‘선언
Public Property CurrencyDecimalDigits As Integer
‘사용 방법
Dim instance As NumberFormatInfo
Dim value As Integer

value = instance.CurrencyDecimalDigits

instance.CurrencyDecimalDigits = value
public int CurrencyDecimalDigits { get; set; }
public:
property int CurrencyDecimalDigits {
    int get ();
    void set (int value);
}
/** @property */
public int get_CurrencyDecimalDigits ()

/** @property */
public void set_CurrencyDecimalDigits (int value)
public function get CurrencyDecimalDigits () : int

public function set CurrencyDecimalDigits (value : int)

속성 값

통화 값에 사용할 소수 자릿수입니다. InvariantInfo 기본값은 2입니다.

예외

예외 형식 조건

ArgumentOutOfRangeException

속성을 0보다 작은 값이나 99보다 큰 값으로 설정하는 경우

InvalidOperationException

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

예제

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

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 negative value with the default number of decimal digits (2).
      Dim myInt As Int64 = - 1234
      Console.WriteLine(myInt.ToString("C", nfi))

      ' Displays the same value with four decimal digits.
      nfi.CurrencyDecimalDigits = 4
      Console.WriteLine(myInt.ToString("C", nfi))

   End Sub 'Main 

End Class 'NumberFormatInfoSample


' This code produces the following output.
'
' ($1,234.00)
' ($1,234.0000)
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 negative value with the default number of decimal digits (2).
      Int64 myInt = -1234;
      Console.WriteLine( myInt.ToString( "C", nfi ) );

      // Displays the same value with four decimal digits.
      nfi.CurrencyDecimalDigits = 4;
      Console.WriteLine( myInt.ToString( "C", nfi ) );

   }
}


/* 
This code produces the following output.

($1,234.00)
($1,234.0000)
*/
   
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 negative value with the default number of decimal digits (2).
   Int64 myInt = -1234;
   Console::WriteLine( myInt.ToString( "C", nfi ) );
   
   // Displays the same value with four decimal digits.
   nfi->CurrencyDecimalDigits = 4;
   Console::WriteLine( myInt.ToString( "C", nfi ) );
}

/* 
This code produces the following output.

($1, 234.00)
($1, 234.0000)
*/
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 negative value with the default number of decimal 
        // digits (2).
        Int64 myInt = (Int64)(-1234);
        Console.WriteLine(myInt.ToString("C", nfi));
        // Displays the same value with four decimal digits.
        nfi.set_CurrencyDecimalDigits(4);
        Console.WriteLine(myInt.ToString("C", nfi));
    } //main 
} //NumberFormatInfoSample

/* 
This code produces the following output.

($1,234.00)
($1,234.0000)
*/

플랫폼

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 네임스페이스
CurrencyDecimalSeparator
CurrencyGroupSeparator
CurrencyGroupSizes
CurrencySymbol
CurrencyNegativePattern
CurrencyPositivePattern
NumberDecimalDigits
PercentDecimalDigits