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 字元指派給其 NegativeSign 屬性 (U+203E) 。 然後,它會使用此 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

備註

這個屬性用於格式化和剖析作業。 如需在格式化作業中使用的詳細資訊,請參閱 標準數值格式字串自訂數值格式字串 主題。

適用於

另請參閱