NumberFormatInfo.NegativeSign 屬性
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定代表相關數字為負數的字串。
public:
property System::String ^ NegativeSign { System::String ^ get(); void set(System::String ^ value); };
C#
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 它會使用此物件來格式化負數浮點數的數位。
C#
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
此屬性用於格式化和剖析作業。 如需格式化作業使用的詳細資訊,請參閱 標準數值格式字串 和 自定義數值格式字串 主題。
產品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |