NumberFormatInfo.NegativeSign
Property
Definition
Gets or sets the string that denotes that the associated number is negative.
public string NegativeSign { get; set; }
The string that denotes that the associated number is negative. The default for InvariantInfo is "-".
The property is being set to null.
The property is being set and the NumberFormatInfo object is read-only.
Examples
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. 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
Remarks
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.