Gets or sets the format of negative percent values.
A int between 0 and 2 inclusive that specifies the format of negative percent values.
Type Reason ArgumentOutOfRangeException The value specified for a set operation is less than 0 or greater than 2. InvalidOperationException The current instance is read-only and a set operation was attempted.
The following table describes the valid values for this property. "%" is used as the value for NumberFormatInfo.PercentSymbol, "-" is used as the value for NumberFormatInfo.NegativeSign, and 999 represents any numeric value.
Value Pattern 0 -999 % 1 -999% 2 -%999 The culture-invariant value for this property is 0.
The following example demonstrates the effects of different NumberFormatInfo.PercentNegativePattern property values.
C# Example
using System; using System.Globalization; class Test { public static void Main() { NumberFormatInfo nfi = new NumberFormatInfo(); decimal data = -.9900m; for (int i = 0; i<=2 ; i++) { nfi.PercentNegativePattern = i; Console.WriteLine("pattern # {0}: {1}",i,data.ToString("P",nfi)); } } }The output is
pattern # 0: -99.00 %
pattern # 1: -99.00%
pattern # 2: -%99.00
Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0