NumberFormatInfo.NegativeSign プロパティ

定義

関連付けられた数値が負であることを示す文字列を取得または設定します。

public:
 property System::String ^ NegativeSign { System::String ^ get(); void set(System::String ^ value); };
public string NegativeSign { get; set; }
member this.NegativeSign : string with get, set
Public Property NegativeSign As String

プロパティ値

関連付けられた数値が負であることを示す文字列。 InvariantInfo の既定値は "-" です。

例外

プロパティが null に設定されています。

このプロパティが設定されていますが、NumberFormatInfo オブジェクトは読み取り専用です。

次の例では、インバリアント カルチャを表す読み取り/書き込み CultureInfo オブジェクトをインスタンス化し、OVERLINE 文字 (U+203E) をプロパティ NegativeSign に割り当てます。 次に、この CultureInfo オブジェクトを使用して、負の浮動小数点数の配列を書式設定します。

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      CultureInfo ci = CultureInfo.CreateSpecificCulture("");
      ci.NumberFormat.NegativeSign = "\u203E";
      double[] numbers = { -1.0, -16.3, -106.35 };

      foreach (var number in numbers)
         Console.WriteLine(number.ToString(ci));
   }
}
// The example displays the following output:
//       ‾1
//       ‾16.3
//       ‾106.35
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim ci As CultureInfo = CultureInfo.CreateSpecificCulture("")
      ci.NumberFormat.NegativeSign = ChrW(&h203E)
      Dim numbers() As Double = { -1.0, -16.3, -106.35 }

      For Each number In numbers
         Console.WriteLine(number.ToString(ci))
      Next
   End Sub
End Module
' The example displays the following output:
'       ‾1
'       ‾16.3
'       ‾106.35

注釈

このプロパティは、書式設定操作と解析操作の両方で使用されます。 書式設定操作での使用の詳細については、「 標準の数値書式指定文字列 」および 「カスタム数値書式指定文字列 」トピックを参照してください。

適用対象

こちらもご覧ください