Mono Class Library: System.Globalization.NumberFormatInfo Overview | Members

System.Globalization.NumberFormatInfo.NumberNegativePattern Property

Gets or sets the format of negative values. [Edit]

public int NumberNegativePattern { set; get; }

Value

A int between 0 and 4 inclusive that specifies the format of negative values. [Edit]

Exceptions

TypeReason
ArgumentOutOfRangeExceptionThe value specified for a set operation is less than 0 or greater than 4. [Edit]
InvalidOperationExceptionThe current instance is read-only and a set operation was attempted. [Edit]

Remarks

The following table describes the valid values for this property. "-" is used as the value for NumberFormatInfo.NegativeSign, and 999 represents any numeric value.

ValuePattern
0(999)
1-999
2- 999
3999-
4999 -

The culture-invariant value for this property is 1.

[Edit]

Example

The following example demonstrates the effects of different NumberFormatInfo.NumberNegativePattern property values.

C# Example
using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 Double data = -9999999999999.00;
 for (int i = 0; i<=4; i++) {
 nfi.NumberNegativePattern = i;
 Console.WriteLine("pattern # {0}: {1}",i,data.ToString("N",nfi));
 }
 }
}
   

The output is

pattern # 0: (9,999,999,999,999.00)
pattern # 1: -9,999,999,999,999.00
pattern # 2: - 9,999,999,999,999.00
pattern # 3: 9,999,999,999,999.00-
pattern # 4: 9,999,999,999,999.00 -

Requirements

Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0