NumberFormatInfo.NumberNegativePattern NumberFormatInfo.NumberNegativePattern NumberFormatInfo.NumberNegativePattern NumberFormatInfo.NumberNegativePattern Property

定義

負の数値の形式パターンを取得または設定します。Gets or sets the format pattern for negative numeric values.

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

プロパティ値

負の数値の形式パターン。The format pattern for negative numeric values.

例外

プロパティが、0 より小さい値か、4 より大きい値に設定されています。The property is being set to a value that is less than 0 or greater than 4.

このプロパティが設定されていますが、NumberFormatInfo オブジェクトは読み取り専用です。The property is being set and the NumberFormatInfo object is read-only.

次の例は、異なる値を表示します。NumberNegativePatternパターン。The following example displays a value using different NumberNegativePattern patterns.

using namespace System;
using namespace System::Globalization;

int main()
{
   // Create a new NumberFormatinfo.
   NumberFormatInfo^ nfi = gcnew NumberFormatInfo;
   
   // Takes a negative value.
   Int64 value = -1234;
   
   // Displays the value with default formatting.
   Console::WriteLine("{0,-20} {1,-10}", "Default:", 
                          value.ToString("N", nfi));
   
   // Displays the value with other patterns.
   for (int i = 0; i <= 4; i++) {
      nfi->NumberNegativePattern = i;
      Console::WriteLine("{0,-20} {1,-10}", 
                              String::Format("Pattern {0}:", 
                                             nfi->NumberNegativePattern), 
                              value.ToString("N", nfi));
   }
}
// The example displays the following output:
//       Default:             -1,234.00
//       Pattern 0:           (1,234.00)
//       Pattern 1:           -1,234.00
//       Pattern 2:           - 1,234.00
//       Pattern 3:           1,234.00-
//       Pattern 4:           1,234.00 -
 using System;
 using System.Globalization;
 
 class Example
 {
     public static void Main()  {
 
       // Create a new NumberFormatinfo.
       NumberFormatInfo nfi = new NumberFormatInfo();

       // Define a negative value.
       Int64 value = -1234;

       // Display the value with default formatting.
        Console.WriteLine("{0,-20} {1,-10}", "Default:", 
                          value.ToString("N", nfi));

       // Display the value with other patterns.
       for (int i = 0; i <= 4; i++)  {
          nfi.NumberNegativePattern = i;
            Console.WriteLine("{0,-20} {1,-10}", 
                              String.Format("Pattern {0}:", 
                                            nfi.NumberNegativePattern), 
                              value.ToString("N", nfi));
       }
   }
}
// The example displays the following output:
//       Default:             -1,234.00
//       Pattern 0:           (1,234.00)
//       Pattern 1:           -1,234.00
//       Pattern 2:           - 1,234.00
//       Pattern 3:           1,234.00-
//       Pattern 4:           1,234.00 -
Imports System.Globalization

Module Example
    Public Sub Main()
        ' Creates a new NumberFormatinfo.
        Dim nfi As New NumberFormatInfo()
        
        ' Define a negative value.
        Dim value As Int64 = -1234
        
        ' Display the value with default formatting.
        Console.WriteLine("{0,-20} {1,-10}", "Default:", 
                          value.ToString("N", nfi))
        
        ' Display the value with other patterns.
        For i As Integer = 0 To 4
            nfi.NumberNegativePattern = i
            Console.WriteLine("{0,-20} {1,-10}", 
                              String.Format("Pattern {0}:", 
                                            nfi.NumberNegativePattern), 
                              value.ToString("N", nfi))
        Next 
    End Sub
End Module
' The example displays the following output:
'       Default:             -1,234.00
'       Pattern 0:           (1,234.00)
'       Pattern 1:           -1,234.00
'       Pattern 2:           - 1,234.00
'       Pattern 3:           1,234.00-
'       Pattern 4:           1,234.00 -

注釈

NumberNegativePatternプロパティは、"N"の標準の数値書式指定文字列でフォーマットされた負の値の書式を定義します。The NumberNegativePattern property defines the format of negative values formatted with the "N" standard numeric format string. このプロパティは、次の表に、値の 1 つを持ちます。This property has one of the values in the following table. シンボル"-"は、NegativeSignnは数値です。The symbol "-" is the NegativeSign and n is a number.

[値]Value 関連付けられているパターンAssociated pattern
00 (n)(n)
11 -n-n
22 -n- n
33 n-n-
44 n -n -

によって返されるインバリアント カルチャの既定値、InvariantInfoプロパティを表す、1 は、"-n"ここで、 nは数値です。The default value for the invariant culture returned by the InvariantInfo property is 1, which represents "-n", where n is a number.

適用対象

こちらもご覧ください