Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

NumberFormatInfo.NegativeSign Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets or sets the string that denotes that the associated number is negative.

Namespace:   System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

public string NegativeSign { get; set; }

Property Value

Type: System.String

The string that denotes that the associated number is negative. The default for InvariantInfo is "-".

Exception Condition
ArgumentNullException

The property is being set to null.

InvalidOperationException

The property is being set and the NumberFormatInfo object is read-only.

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.

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

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2017 Microsoft