NumberFormatInfo.NegativeSign NumberFormatInfo.NegativeSign NumberFormatInfo.NegativeSign NumberFormatInfo.NegativeSign Property

定义

获取或设置表示关联数字是负值的字符串。Gets or sets the string that denotes that the associated number is negative.

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

属性值

表示关联数字是负值的字符串。The string that denotes that the associated number is negative. InvariantInfo 默认为“-”。The default for InvariantInfo is "-".

异常

该属性设置为 nullThe property is being set to null.

设置了该属性,但 NumberFormatInfo 对象为只读。The property is being set and the NumberFormatInfo object is read-only.

示例

下面的示例实例化一个读写CultureInfo对象,表示固定区域性并将上划线字符 (U + 203E) 分配给其NegativeSign属性。The following example instantiates a read-write CultureInfo object that represents the invariant culture and assigns the OVERLINE character (U+203E) to its NegativeSign property. 然后,它使用此CultureInfo要设置格式的负浮点数数组对象。It then uses this CultureInfo object to format an array of negative floating-point numbers.

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(culture));
   }
}
// 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(culture))
      Next
   End Sub
End Module
' The example displays the following output:
'       ‾1
'       ‾16.3
'       ‾106.35

注解

在格式设置和分析操作中使用此属性。This property is used in both formatting and parsing operations. 在格式设置操作中使用的详细信息,请参阅标准数字格式字符串自定义数字格式字符串主题。For more information on its use in formatting operations, see the Standard Numeric Format Strings and Custom Numeric Format Strings topics.

适用于

另请参阅