NumberFormatInfo.CurrencyDecimalDigits Свойство

Определение

Возвращает или задает количество десятичных разрядов, используемых в значениях валют.

public:
 property int CurrencyDecimalDigits { int get(); void set(int value); };
public int CurrencyDecimalDigits { get; set; }
member this.CurrencyDecimalDigits : int with get, set
Public Property CurrencyDecimalDigits As Integer

Значение свойства

Количество десятичных разрядов, используемых в значениях валют. Значение по умолчанию InvariantInfo — 2.

Исключения

Свойство задается значением, которое меньше 0 или больше 99.

Свойство задано, и NumberFormatInfo объект доступен только для чтения.

Примеры

В следующем примере показано влияние изменения CurrencyDecimalDigits свойства.

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)
*/
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

End Class


' This code produces the following output.
'
' ($1,234.00)
' ($1,234.0000)

Комментарии

Свойство CurrencyDecimalDigits используется со строкой стандартного формата "C" без описатель точности в числовых операциях форматирования. Он определяет число дробных цифр по умолчанию, которое отображается после десятичного разделителя. Это значение переопределяется, если используется описатель точности. Дополнительные сведения см. в разделе "Строки стандартного числового формата".

Применяется к

См. также раздел