NumberFormatInfo.NegativeSign Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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. The default for InvariantInfo is "-".
The property is being set to null
.
The property is being set and the NumberFormatInfo object is read-only.
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(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
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.
Product | Versions |
---|---|
.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 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: