다음을 통해 공유


NumberFormatInfo.NumberNegativePattern 속성

음수 숫자 값의 서식 패턴을 가져오거나 설정합니다.

네임스페이스: System.Globalization
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
Public Property NumberNegativePattern As Integer
‘사용 방법
Dim instance As NumberFormatInfo
Dim value As Integer

value = instance.NumberNegativePattern

instance.NumberNegativePattern = value
public int NumberNegativePattern { get; set; }
public:
property int NumberNegativePattern {
    int get ();
    void set (int value);
}
/** @property */
public int get_NumberNegativePattern ()

/** @property */
public void set_NumberNegativePattern (int value)
public function get NumberNegativePattern () : int

public function set NumberNegativePattern (value : int)

속성 값

음수 숫자 값의 서식 패턴입니다. InvariantInfo의 기본값은 "-n"을 나타내는 1입니다. 여기서, n은 숫자입니다.

예외

예외 형식 조건

ArgumentOutOfRangeException

속성을 0보다 작은 값이나 4보다 큰 값으로 설정하는 경우

InvalidOperationException

속성이 설정되어 있으며 NumberFormatInfo는 읽기 전용인 경우

설명

이 속성은 다음 표의 값 중 하나입니다. "-" 기호는 NegativeSign이며 n은 숫자입니다.

관련 패턴

0

(n)

1

-n

2

- n

3

n-

4

n -

예제

다음 코드 예제에서는 다양한 NumberNegativePattern 패턴을 사용하여 값을 출력합니다.

Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic

Class SamplesNumberFormatInfo    
    
    Public Shared Sub Main()
        
        ' Creates a new NumberFormatinfo.
        Dim myNfi As New NumberFormatInfo()
        
        ' Takes a negative value.
        Dim myInt As Int64 = - 1234
        
        ' Displays the value with default formatting.
        Console.WriteLine("Default  " + ControlChars.Tab + ":" _
           + ControlChars.Tab + "{0}", myInt.ToString("N", myNfi))
        
        ' Displays the value with other patterns.
        Dim i As Integer
        For i = 0 To 4
            myNfi.NumberNegativePattern = i
            Console.WriteLine("Pattern {0}" + ControlChars.Tab + ":" _
               + ControlChars.Tab + "{1}", myNfi.NumberNegativePattern, _
               myInt.ToString("N", myNfi))
        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 -
 using System;
 using System.Globalization;
 class SamplesNumberFormatInfo  {
 
    public static void Main()  {
 
       // Creates a new NumberFormatinfo.
       NumberFormatInfo myNfi = new NumberFormatInfo();

       // Takes a negative value.
       Int64 myInt = -1234;

       // Displays the value with default formatting.
       Console.WriteLine( "Default  \t:\t{0}", myInt.ToString( "N", myNfi ) );

       // Displays the value with other patterns.
       for ( int i = 0; i <= 4; i++ )  {
          myNfi.NumberNegativePattern = i;
          Console.WriteLine( "Pattern {0}\t:\t{1}", myNfi.NumberNegativePattern, myInt.ToString( "N", myNfi ) );
       }
    }
 }
 /*
 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 -
*/
using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Creates a new NumberFormatinfo.
   NumberFormatInfo^ myNfi = gcnew NumberFormatInfo;
   
   // Takes a negative value.
   Int64 myInt = -1234;
   
   // Displays the value with default formatting.
   Console::WriteLine( "Default  \t:\t {0}", myInt.ToString( "N", myNfi ) );
   
   // Displays the value with other patterns.
   for ( int i = 0; i <= 4; i++ )
   {
      myNfi->NumberNegativePattern = i;
      Console::WriteLine( "Pattern {0}\t:\t {1}", myNfi->NumberNegativePattern, myInt.ToString( "N", myNfi ) );

   }
}

/*
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 -
*/
import System.*;
import System.Globalization.*;

class SamplesNumberFormatInfo
{
    public static void main(String[] args)
    {
        // Creates a new NumberFormatinfo.
        NumberFormatInfo myNfi = new NumberFormatInfo();
        // Takes a negative value.
        Int64 myInt = (Int64)(-1234);
        // Displays the value with default formatting.
        Console.WriteLine("Default  \t:\t{0}", myInt.ToString("N", myNfi));
        // Displays the value with other patterns.
        for (int i = 0; i <= 4; i++) {
            myNfi.set_NumberNegativePattern(i);
            Console.WriteLine("Pattern {0}\t:\t{1}", (Int32)myNfi.
                get_NumberNegativePattern(), myInt.ToString("N", myNfi));
        }
    } //main
} //SamplesNumberFormatInfo

/*
 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 -
*/
import System
import System.Globalization

// Creates a new NumberFormatinfo.
var myNfi : NumberFormatInfo = new NumberFormatInfo()

// Takes a negative value.
var myInt : Int64 = - 1234

// Displays the value with default formatting.
Console.WriteLine("Default  \t:\t{0}", myInt.ToString("N", myNfi))

// Displays the value with other patterns.
for(var i = 0; i < 5; i++){
    myNfi.NumberNegativePattern = i
    Console.WriteLine("Pattern {0}\t:\t{1}", myNfi.NumberNegativePattern, myInt.ToString("N", myNfi))
}

// 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 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

NumberFormatInfo 클래스
NumberFormatInfo 멤버
System.Globalization 네임스페이스
NumberFormatInfo.NumberDecimalDigits 속성
NumberFormatInfo.NumberDecimalSeparator 속성
NumberFormatInfo.NumberGroupSeparator 속성
NumberFormatInfo.NumberGroupSizes 속성
NumberFormatInfo.NaNSymbol 속성
NumberFormatInfo.CurrencyNegativePattern 속성
PercentNegativePattern