System.Globalization.NumberFormatInfo.CurrencyNegativePattern Property

Gets or sets the format pattern for negative currency values.

Syntax

public int CurrencyNegativePattern { get; set; }

Value

A int between 0 and 15 inclusive, which specifies the format of negative currency values.

Exceptions

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

Remarks

The NumberFormatInfo.CurrencyNegativePattern property is used with the "C" standard format string to define the pattern of negative currency values. For more information, see Standard Numeric Format Strings. This property has one of the values in the following table. The symbol "$" is the NumberFormatInfo.CurrencySymbol, the symbol "-" is the NumberFormatInfo.NegativeSign, and n is a number.

0

($n)

1

-$n

2

$-n

3

$n-

4

(n$)

5

-n$

6

n-$

7

n$-

8

-n $

9

-$ n

10

n $-

11

$ n-

12

$ -n

13

n- $

14

($ n)

15

(n $)

Example

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

C# Example

using System;
using System.Globalization;
class Test {
 public static void Main() {
 NumberFormatInfo nfi = new NumberFormatInfo();
 decimal myMoney = -9999999999999.00m;
 for (int i = 0; i<=15; i++) {
 nfi.CurrencyNegativePattern = i;
 Console.WriteLine("pattern # {0}: {1}",i,myMoney.ToString("C",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$)
pattern # 5: -9,999,999,999,999.00$
pattern # 6: 9,999,999,999,999.00-$
pattern # 7: 9,999,999,999,999.00$-
pattern # 8: -9,999,999,999,999.00 $
pattern # 9: -$ 9,999,999,999,999.00
pattern # 10: 9,999,999,999,999.00 $-
pattern # 11: $ 9,999,999,999,999.00-
pattern # 12: $ -9,999,999,999,999.00
pattern # 13: 9,999,999,999,999.00- $
pattern # 14: ($ 9,999,999,999,999.00)
pattern # 15: (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, 4.0.0.0