NumberNegativePattern Property

NumberFormatInfo.NumberNegativePattern Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the format pattern for negative numeric values.

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

'Declaration
Public Property NumberNegativePattern As Integer

Property Value

Type: System.Int32
The format pattern for negative numeric values. The default for InvariantInfo is 1, which represents "-n", where n is a number.

ExceptionCondition
ArgumentOutOfRangeException

The property is being set to a value that is less than 0 or greater than 4.

InvalidOperationException

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

This property has one of the values in the following table. The symbol "-" is the NegativeSign and n is a number.

Value

Associated pattern

0

(n)

1

-n

2

- n

3

n-

4

n -

The following example prints a value using different NumberNegativePattern patterns.


Imports System.Globalization

Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)

      ' Creates a new NumberFormatinfo.
      Dim myNfi As New NumberFormatInfo()

      ' Takes a negative value.
      Dim myInt As Int64 = -1234

      ' Displays the value with default formatting.
      outputBlock.Text += String.Format("Default  " + ControlChars.Tab + ":" _
         + ControlChars.Tab + "{0}", myInt.ToString("N", myNfi)) + vbCrLf

      ' Displays the value with other patterns.
      Dim i As Integer
      For i = 0 To 4
         myNfi.NumberNegativePattern = i
         outputBlock.Text += String.Format("Pattern {0}" + ControlChars.Tab + ":" _
            + ControlChars.Tab + "{1}", myNfi.NumberNegativePattern, _
            myInt.ToString("N", myNfi)) + vbCrLf
      Next i
   End Sub
End Class

' This code produces the following output.
' 
' Default         :       (1,234.00)
' Pattern 0       :       (1,234.00)
' Pattern 1       :       -1,234.00
' Pattern 2       :       - 1,234.00
' Pattern 3       :       1,234.00-
' Pattern 4       :       1,234.00 -


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft