다음을 통해 공유


UInt32.Parse 메서드

정의

숫자의 문자열 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

오버로드

Name Description
Parse(String, NumberStyles, IFormatProvider)

지정된 스타일 및 문화권별 형식의 숫자 문자열 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)

지정된 스타일 및 문화권별 형식의 숫자 범위 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

Parse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider)

UTF-8 문자의 범위를 값으로 구문 분석합니다.

Parse(String, IFormatProvider)

지정된 문화권별 형식의 숫자 문자열 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

Parse(ReadOnlySpan<Char>, IFormatProvider)

문자 범위를 값으로 구문 분석합니다.

Parse(ReadOnlySpan<Byte>, IFormatProvider)

UTF-8 문자의 범위를 값으로 구문 분석합니다.

Parse(String)

숫자의 문자열 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

Parse(String, NumberStyles)

지정된 스타일의 숫자 문자열 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

Parse(String, NumberStyles, IFormatProvider)

Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs

Important

이 API는 CLS 규격이 아닙니다.

CLS 대체 규격
System.Int64.Parse(String)

지정된 스타일 및 문화권별 형식의 숫자 문자열 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

public:
 static System::UInt32 Parse(System::String ^ s, System::Globalization::NumberStyles style, IFormatProvider ^ provider);
public:
 static System::UInt32 Parse(System::String ^ s, System::Globalization::NumberStyles style, IFormatProvider ^ provider) = System::Numerics::INumberBase<System::UInt32>::Parse;
[System.CLSCompliant(false)]
public static uint Parse(string s, System.Globalization.NumberStyles style, IFormatProvider provider);
public static uint Parse(string s, System.Globalization.NumberStyles style, IFormatProvider? provider);
[System.CLSCompliant(false)]
public static uint Parse(string s, System.Globalization.NumberStyles style, IFormatProvider? provider);
[<System.CLSCompliant(false)>]
static member Parse : string * System.Globalization.NumberStyles * IFormatProvider -> uint32
static member Parse : string * System.Globalization.NumberStyles * IFormatProvider -> uint32
Public Shared Function Parse (s As String, style As NumberStyles, provider As IFormatProvider) As UInteger

매개 변수

s
String

변환할 숫자를 나타내는 문자열입니다. 문자열은 매개 변수로 지정된 스타일을 사용하여 해석됩니다 style .

style
NumberStyles

에 있을 s수 있는 스타일 요소를 나타내는 열거형 값의 비트 조합입니다. 지정하는 일반적인 값은 .입니다 Integer.

provider
IFormatProvider

에 대한 문화권별 서식 정보를 제공하는 개체입니다 s.

반환

에 지정된 수에 해당하는 부호 없는 32비트 정수입니다 s.

구현

특성

예외

snull입니다.

style가 값이 아닌 경우 NumberStyles

-또는-

style은 값과 HexNumber 값의 조합이 AllowHexSpecifier 아닙니다.

s 가 .와 호환 style되는 형식이 아닌 경우

sUInt32.MinValue 보다 작거나 UInt32.MaxValue보다 큰 숫자를 나타냅니다.

-또는-

s 에는 0이 아닌 소수 자릿수가 포함됩니다.

예제

다음 예제에서는 메서드를 Parse(String, NumberStyles, IFormatProvider) 사용하여 숫자의 다양한 문자열 표현을 부호 없는 32비트 정수 값으로 변환합니다.

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      string[] cultureNames= { "en-US", "fr-FR" };
      NumberStyles[] styles= { NumberStyles.Integer,
                               NumberStyles.Integer | NumberStyles.AllowDecimalPoint };
      string[] values = { "170209", "+170209.0", "+170209,0", "-103214.00",
                                 "-103214,00", "104561.1", "104561,1" };
      
      // Parse strings using each culture
      foreach (string cultureName in cultureNames)
      {
         CultureInfo ci = new CultureInfo(cultureName);
         Console.WriteLine("Parsing strings using the {0} culture", 
                           ci.DisplayName);
         // Use each style.
         foreach (NumberStyles style in styles)
         {
            Console.WriteLine("   Style: {0}", style.ToString());
            // Parse each numeric string.
            foreach (string value in values)
            {
               try {
                  Console.WriteLine("      Converted '{0}' to {1}.", value,
                                    UInt32.Parse(value, style, ci));
               }
               catch (FormatException) {
                  Console.WriteLine("      Unable to parse '{0}'.", value);
               }      
               catch (OverflowException) {
                  Console.WriteLine("      '{0}' is out of range of the UInt32 type.",
                                    value);
               }
            }
         }
      }                                    
   }
}
// The example displays the following output:
//       Parsing strings using the English (United States) culture
//          Style: Integer
//             Converted '170209' to 170209.
//             Unable to parse '+170209.0'.
//             Unable to parse '+170209,0'.
//             Unable to parse '-103214.00'.
//             Unable to parse '-103214,00'.
//             Unable to parse '104561.1'.
//             Unable to parse '104561,1'.
//          Style: Integer, AllowDecimalPoint
//             Converted '170209' to 170209.
//             Converted '+170209.0' to 170209.
//             Unable to parse '+170209,0'.
//             '-103214.00' is out of range of the UInt32 type.
//             Unable to parse '-103214,00'.
//             '104561.1' is out of range of the UInt32 type.
//             Unable to parse '104561,1'.
//       Parsing strings using the French (France) culture
//          Style: Integer
//             Converted '170209' to 170209.
//             Unable to parse '+170209.0'.
//             Unable to parse '+170209,0'.
//             Unable to parse '-103214.00'.
//             Unable to parse '-103214,00'.
//             Unable to parse '104561.1'.
//             Unable to parse '104561,1'.
//          Style: Integer, AllowDecimalPoint
//             Converted '170209' to 170209.
//             Unable to parse '+170209.0'.
//             Converted '+170209,0' to 170209.
//             Unable to parse '-103214.00'.
//             '-103214,00' is out of range of the UInt32 type.
//             Unable to parse '104561.1'.
//             '104561,1' is out of range of the UInt32 type.
open System
open System.Globalization

let cultureNames = [| "en-US"; "fr-FR" |]
let styles = 
    [| NumberStyles.Integer; NumberStyles.Integer ||| NumberStyles.AllowDecimalPoint |]
let values = 
    [| "170209"; "+170209.0"; "+170209,0"; "-103214.00"; "-103214,00"; "104561.1"; "104561,1" |]

// Parse strings using each culture
for cultureName in cultureNames do
    let ci = CultureInfo cultureName
    printfn $"Parsing strings using the {ci.DisplayName} culture"
    // Use each style.
    for style in styles do
        printfn $"   Style: {style}"
        // Parse each numeric string.
        for value in values do
            try
                printfn $"      Converted '{value}' to {UInt32.Parse(value, style, ci)}."
            with
            | :? FormatException ->
                printfn $"      Unable to parse '{value}'."
            | :? OverflowException ->
                printfn $"      '{value}' is out of range of the UInt32 type."
// The example displays the following output:
//       Parsing strings using the English (United States) culture
//          Style: Integer
//             Converted '170209' to 170209.
//             Unable to parse '+170209.0'.
//             Unable to parse '+170209,0'.
//             Unable to parse '-103214.00'.
//             Unable to parse '-103214,00'.
//             Unable to parse '104561.1'.
//             Unable to parse '104561,1'.
//          Style: Integer, AllowDecimalPoint
//             Converted '170209' to 170209.
//             Converted '+170209.0' to 170209.
//             Unable to parse '+170209,0'.
//             '-103214.00' is out of range of the UInt32 type.
//             Unable to parse '-103214,00'.
//             '104561.1' is out of range of the UInt32 type.
//             Unable to parse '104561,1'.
//       Parsing strings using the French (France) culture
//          Style: Integer
//             Converted '170209' to 170209.
//             Unable to parse '+170209.0'.
//             Unable to parse '+170209,0'.
//             Unable to parse '-103214.00'.
//             Unable to parse '-103214,00'.
//             Unable to parse '104561.1'.
//             Unable to parse '104561,1'.
//          Style: Integer, AllowDecimalPoint
//             Converted '170209' to 170209.
//             Unable to parse '+170209.0'.
//             Converted '+170209,0' to 170209.
//             Unable to parse '-103214.00'.
//             '-103214,00' is out of range of the UInt32 type.
//             Unable to parse '104561.1'.
//             '104561,1' is out of range of the UInt32 type.
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim cultureNames() As String = { "en-US", "fr-FR" }
      Dim styles() As NumberStyles = { NumberStyles.Integer, _
                                       NumberStyles.Integer Or NumberStyles.AllowDecimalPoint }
      Dim values() As String = { "170209", "+170209.0", "+170209,0", "-103214.00", _
                                 "-103214,00", "104561.1", "104561,1" }
      
      ' Parse strings using each culture
      For Each cultureName As String In cultureNames
         Dim ci As New CultureInfo(cultureName)
         Console.WriteLine("Parsing strings using the {0} culture", ci.DisplayName)
         ' Use each style.
         For Each style As NumberStyles In styles
            Console.WriteLine("   Style: {0}", style.ToString())
            ' Parse each numeric string.
            For Each value As String In values
               Try
                  Console.WriteLine("      Converted '{0}' to {1}.", value, _
                                    UInt32.Parse(value, style, ci))
               Catch e As FormatException
                  Console.WriteLine("      Unable to parse '{0}'.", value)   
               Catch e As OverflowException
                  Console.WriteLine("      '{0}' is out of range of the UInt32 type.", _
                                    value)         
               End Try
            Next
         Next
      Next                                    
   End Sub
End Module
' The example displays the following output:
'       Parsing strings using the English (United States) culture
'          Style: Integer
'             Converted '170209' to 170209.
'             Unable to parse '+170209.0'.
'             Unable to parse '+170209,0'.
'             Unable to parse '-103214.00'.
'             Unable to parse '-103214,00'.
'             Unable to parse '104561.1'.
'             Unable to parse '104561,1'.
'          Style: Integer, AllowDecimalPoint
'             Converted '170209' to 170209.
'             Converted '+170209.0' to 170209.
'             Unable to parse '+170209,0'.
'             '-103214.00' is out of range of the UInt32 type.
'             Unable to parse '-103214,00'.
'             '104561.1' is out of range of the UInt32 type.
'             Unable to parse '104561,1'.
'       Parsing strings using the French (France) culture
'          Style: Integer
'             Converted '170209' to 170209.
'             Unable to parse '+170209.0'.
'             Unable to parse '+170209,0'.
'             Unable to parse '-103214.00'.
'             Unable to parse '-103214,00'.
'             Unable to parse '104561.1'.
'             Unable to parse '104561,1'.
'          Style: Integer, AllowDecimalPoint
'             Converted '170209' to 170209.
'             Unable to parse '+170209.0'.
'             Converted '+170209,0' to 170209.
'             Unable to parse '-103214.00'.
'             '-103214,00' is out of range of the UInt32 type.
'             Unable to parse '104561.1'.
'             '104561,1' is out of range of the UInt32 type.

설명

매개 변수는 style 구문 분석 작업이 성공하기 위해 매개 변수에 s 허용되는 스타일 요소(예: 공백 또는 양수 또는 음수 기호)를 정의합니다. 열거형의 비트 플래그 NumberStyles 조합이어야 합니다.

style에 따라 매개 변수에는 s 다음 요소가 포함될 수 있습니다.

[ws][$][sign]digits[.fractional_digits][E[sign]exponential_digits][ws]

대괄호([ 및 ])의 요소는 선택 사항입니다. 포함된 style경우 NumberStyles.AllowHexSpecifier 매개 변수에는 s 다음 요소가 포함될 수 있습니다.

[ws]hexdigits[ws]

다음 표에서는 각 요소에 대해 설명합니다.

요소 묘사
ws 선택적 공백입니다. 플래그가 포함된 경우 style 의 시작 부분에 s 공백이 NumberStyles.AllowLeadingWhite 표시될 수 있으며 플래그를 포함하는 NumberStyles.AllowTrailingWhite 경우 style 끝에 s 표시될 수 있습니다.
$ 문화권별 통화 기호입니다. 문자열의 위치는 매개 변수 메서드에서 반환되는 개체의 NumberFormatInfoprovider 속성에 GetFormat 의해 CurrencyPositivePattern 정의됩니다. 플래그를 포함하는 경우 s 통화 기호가 style 나타날 NumberStyles.AllowCurrencySymbol 수 있습니다.
서명 선택적 기호입니다. (메서드는 음수 OverflowException 기호를 포함하는 if s 를 throw하고 0이 아닌 숫자를 나타냅니다.) 플래그가 포함된 경우 시작 s 부분에 표시할 수 있으며 플래그가 포함된 NumberStyles.AllowTrailingSign 경우 styles 끝에 표시할 수 style 있습니다.NumberStyles.AllowLeadingSign 플래그를 포함하는 s 경우 style 괄호를 사용하여 NumberStyles.AllowParentheses 음수 값을 나타낼 수 있습니다.
자리 0에서 9까지의 숫자 시퀀스입니다.
. 문화권별 소수점 기호입니다. 플래그가 포함된 경우 s 현재 문화권의 소수점 기호가 styleNumberStyles.AllowDecimalPoint 나타날 수 있습니다.
fractional_digits 플래그가 포함된 NumberStyles.AllowExponent 경우 style 숫자 0-9가 하나 이상 발생하거나, 그렇지 않은 경우 숫자 0이 하나 이상 발생합니다. 소수 자릿수는 플래그를 포함하는 경우에만 s 표시 styleNumberStyles.AllowDecimalPoint 수 있습니다.
E 값이 지수(과학적) 표기법으로 표현됨을 나타내는 "e" 또는 "E" 문자입니다. 플래그를 포함하는 경우 s 매개 변수는 style 지수 표기법으로 NumberStyles.AllowExponent 숫자를 나타낼 수 있습니다.
exponential_digits 0에서 9까지의 숫자 시퀀스입니다. 플래그를 포함하는 경우 s 매개 변수는 style 지수 표기법으로 NumberStyles.AllowExponent 숫자를 나타낼 수 있습니다.
hexdigits 0부터 f까지의 16진수 숫자 또는 0부터 F까지의 시퀀스입니다.

메모

인수 값 s 에 관계없이 구문 분석 작업에서 style 종료되는 NUL(U+0000) 문자는 무시됩니다.

10진수만 있는 문자열(스타일에 NumberStyles.None 해당)은 항상 성공적으로 구문 분석됩니다. 나머지 NumberStyles 멤버의 대부분은 이 입력 문자열에 존재할 수 있지만 존재할 필요는 없는 요소를 제어합니다. 다음 표에서는 개별 NumberStyles 멤버가 에 있을 s수 있는 요소에 미치는 영향을 나타냅니다.

복합 값이 NumberStyles 아닌 값 숫자 외에 s 허용되는 요소
NumberStyles.None 10진수에만 해당합니다.
NumberStyles.AllowDecimalPoint 소수점(.) 및 fractional_digits 요소입니다. 그러나 스타일에 플래그가 NumberStyles.AllowExponent 포함되지 않은 경우 fractional_digits 하나 이상의 0자리 숫자로만 구성되어야 합니다. 그렇지 않으면 throw OverflowException 됩니다.
NumberStyles.AllowExponent exponential_digits 함께 지수 표기법을 나타내는 "e" 또는 "E" 문자입니다.
NumberStyles.AllowLeadingWhite 의 시작 부분에 있는 ws 요소입니다 s.
NumberStyles.AllowTrailingWhite 의 끝에 있는 ws 요소입니다 s.
NumberStyles.AllowLeadingSign 숫자 앞의 기호입니다.
NumberStyles.AllowTrailingSign 숫자 뒤의 기호 입니다.
NumberStyles.AllowParentheses 숫자 앞과 뒤 괄호로 하여 음수 값을 나타냅니다.
NumberStyles.AllowThousands 그룹 구분 기호(,) 요소입니다.
NumberStyles.AllowCurrencySymbol currency($) 요소입니다.

플래그를 NumberStyles.AllowHexSpecifier 사용하는 s 경우 16진수 값이어야 합니다. 결합할 수 있는 유일한 다른 플래그는 다음과 NumberStyles.AllowTrailingWhite같습니다NumberStyles.AllowLeadingWhite. (열거형에는 NumberStyles 공백 플래그를 모두 포함하는 복합 숫자 스타일 NumberStyles.HexNumber이 포함됩니다.)

메모

매개 변수가 s 16진수의 문자열 표현인 경우 16진수로 구분하는 데코레이션(예: 0x 또는 &h)이 앞에 올 수 없습니다. 이렇게 하면 구문 분석 작업이 예외를 throw합니다.

provider 매개 변수는 IFormatProvider 메서드가 GetFormat 형식에 대한 문화권별 정보를 제공하는 개체를 반환 NumberFormatInfo 하는 구현입니다s. 매개 변수를 사용하여 provider 구문 분석 작업에 사용자 지정 서식 정보를 제공하는 세 가지 방법이 있습니다.

  • 서식 정보를 제공하는 실제 NumberFormatInfo 개체를 전달할 수 있습니다. (단순히 자신을 반환하는 GetFormat 구현입니다.)

  • 서식을 CultureInfo 사용할 문화권을 지정하는 개체를 전달할 수 있습니다. 해당 속성은 NumberFormat 서식 정보를 제공합니다.

  • 사용자 지정 IFormatProvider 구현을 전달할 수 있습니다. 해당 메서드는 GetFormat 서식 정보를 제공하는 개체를 NumberFormatInfo 인스턴스화하고 반환해야 합니다.

providernull 경우 NumberFormatInfo 현재 문화권의 개체가 사용됩니다.

추가 정보

적용 대상

Parse(ReadOnlySpan<Char>, NumberStyles, IFormatProvider)

Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs

Important

이 API는 CLS 규격이 아닙니다.

지정된 스타일 및 문화권별 형식의 숫자 범위 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

public static uint Parse(ReadOnlySpan<char> s, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Integer, IFormatProvider? provider = default);
[System.CLSCompliant(false)]
public static uint Parse(ReadOnlySpan<char> s, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Integer, IFormatProvider provider = default);
[System.CLSCompliant(false)]
public static uint Parse(ReadOnlySpan<char> s, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Integer, IFormatProvider? provider = default);
static member Parse : ReadOnlySpan<char> * System.Globalization.NumberStyles * IFormatProvider -> uint32
[<System.CLSCompliant(false)>]
static member Parse : ReadOnlySpan<char> * System.Globalization.NumberStyles * IFormatProvider -> uint32
Public Shared Function Parse (s As ReadOnlySpan(Of Char), Optional style As NumberStyles = System.Globalization.NumberStyles.Integer, Optional provider As IFormatProvider = Nothing) As UInteger

매개 변수

s
ReadOnlySpan<Char>

변환할 숫자를 나타내는 문자가 들어 있는 범위입니다. 범위는 매개 변수로 지정된 스타일을 사용하여 해석됩니다 style .

style
NumberStyles

에 있을 s수 있는 스타일 요소를 나타내는 열거형 값의 비트 조합입니다. 지정하는 일반적인 값은 .입니다 Integer.

provider
IFormatProvider

에 대한 문화권별 서식 정보를 제공하는 개체입니다 s.

반환

에 지정된 수에 해당하는 부호 없는 32비트 정수입니다 s.

구현

특성

적용 대상

Parse(ReadOnlySpan<Byte>, NumberStyles, IFormatProvider)

Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs

UTF-8 문자의 범위를 값으로 구문 분석합니다.

public static uint Parse(ReadOnlySpan<byte> utf8Text, System.Globalization.NumberStyles style = System.Globalization.NumberStyles.Integer, IFormatProvider? provider = default);
static member Parse : ReadOnlySpan<byte> * System.Globalization.NumberStyles * IFormatProvider -> uint32
Public Shared Function Parse (utf8Text As ReadOnlySpan(Of Byte), Optional style As NumberStyles = System.Globalization.NumberStyles.Integer, Optional provider As IFormatProvider = Nothing) As UInteger

매개 변수

utf8Text
ReadOnlySpan<Byte>

구문 분석할 UTF-8 문자의 범위입니다.

style
NumberStyles

에 있을 utf8Text수 있는 숫자 스타일의 비트 조합입니다.

provider
IFormatProvider

에 대한 문화권별 서식 정보를 제공하는 개체입니다 utf8Text.

반환

구문 분석의 결과입니다 utf8Text.

구현

적용 대상

Parse(String, IFormatProvider)

Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs

Important

이 API는 CLS 규격이 아닙니다.

CLS 대체 규격
System.Int64.Parse(String)

지정된 문화권별 형식의 숫자 문자열 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

public:
 static System::UInt32 Parse(System::String ^ s, IFormatProvider ^ provider);
public:
 static System::UInt32 Parse(System::String ^ s, IFormatProvider ^ provider) = IParsable<System::UInt32>::Parse;
[System.CLSCompliant(false)]
public static uint Parse(string s, IFormatProvider provider);
public static uint Parse(string s, IFormatProvider? provider);
[System.CLSCompliant(false)]
public static uint Parse(string s, IFormatProvider? provider);
[<System.CLSCompliant(false)>]
static member Parse : string * IFormatProvider -> uint32
static member Parse : string * IFormatProvider -> uint32
Public Shared Function Parse (s As String, provider As IFormatProvider) As UInteger

매개 변수

s
String

변환할 숫자를 나타내는 문자열입니다.

provider
IFormatProvider

에 대한 문화권별 서식 정보를 제공하는 개체입니다 s.

반환

에 지정된 수에 해당하는 부호 없는 32비트 정수입니다 s.

구현

특성

예외

snull입니다.

s 가 올바른 스타일이 아닙니다.

sUInt32.MinValue 보다 작거나 UInt32.MaxValue보다 큰 숫자를 나타냅니다.

예제

다음 예제는 웹 양식의 단추 클릭 이벤트 처리기입니다. 속성에서 반환된 배열을 HttpRequest.UserLanguages 사용하여 사용자의 로캘을 확인합니다. 그런 다음, 해당 로캘에 CultureInfo 해당하는 개체를 인스턴스화합니다. NumberFormatInfo 그런 다음 해당 CultureInfo 개체에 속하는 개체가 메서드에 Parse(String, IFormatProvider) 전달되어 사용자의 입력을 값으로 UInt32 변환합니다.

protected void OkToUInteger_Click(object sender, EventArgs e)
{
    string locale;
    uint number;
    CultureInfo culture;

    // Return if string is empty
    if (String.IsNullOrEmpty(this.inputNumber.Text))
        return;

    // Get locale of web request to determine possible format of number
    if (Request.UserLanguages.Length == 0)
        return;
    locale = Request.UserLanguages[0];
    if (String.IsNullOrEmpty(locale))
        return;

    // Instantiate CultureInfo object for the user's locale
    culture = new CultureInfo(locale);

    // Convert user input from a string to a number
    try
    {
        number = UInt32.Parse(this.inputNumber.Text, culture.NumberFormat);
    }
    catch (FormatException)
    {
        return;
    }
    catch (Exception)
    {
        return;
    }
    // Output number to label on web form
    this.outputNumber.Text = "Number is " + number.ToString();
}
Protected Sub OKToUInteger_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OkToUInteger.Click
    Dim locale As String
    Dim culture As CultureInfo
    Dim number As UInteger

    ' Return if string is empty
    If String.IsNullOrEmpty(Me.inputNumber.Text) Then Exit Sub

    ' Get locale of web request to determine possible format of number
    If Request.UserLanguages.Length = 0 Then Exit Sub
    locale = Request.UserLanguages(0)
    If String.IsNullOrEmpty(locale) Then Exit Sub

    ' Instantiate CultureInfo object for the user's locale
    culture = New CultureInfo(locale)

    ' Convert user input from a string to a number
    Try
        number = UInt32.Parse(Me.inputNumber.Text, culture.NumberFormat)
    Catch ex As FormatException
        Exit Sub
    Catch ex As Exception
        Exit Sub
    End Try

    ' Output number to label on web form
    Me.outputNumber.Text = "Number is " & number.ToString()
End Sub

설명

매개 변수에는 s 다음과 같은 다양한 형식이 포함됩니다.

[ws][sign]digits[ws]

대괄호([ 및 ])의 항목은 선택 사항입니다. 다음 표에서는 각 요소에 대해 설명합니다.

요소 묘사
ws 선택적 공백입니다.
서명 선택적 기호이거나 값 0을 나타내는 경우 s 음수 기호입니다.
자리 0에서 9 사이의 숫자 시퀀스입니다.

s 매개 변수는 스타일을 사용하여 해석됩니다 NumberStyles.Integer . 부호 없는 정수 값의 소수 자릿수 외에도 선행 기호와 함께 선행 및 후행 공백만 허용됩니다. (음수 기호가 있는 s 경우 0 값을 나타내거나 메서드 OverflowException에서 .) 스타일 요소를 문화권별 서식 정보와 함께 명시적으로 정의하려면 메서드 sParse(String, NumberStyles, IFormatProvider) 사용합니다.

provider 매개 변수는 IFormatProvider 메서드가 GetFormat 형식에 대한 문화권별 정보를 제공하는 개체를 반환 NumberFormatInfo 하는 구현입니다s. 매개 변수를 사용하여 provider 구문 분석 작업에 사용자 지정 서식 정보를 제공하는 세 가지 방법이 있습니다.

  • 서식 정보를 제공하는 실제 NumberFormatInfo 개체를 전달할 수 있습니다. (단순히 자신을 반환하는 GetFormat 구현입니다.)

  • 서식을 CultureInfo 사용할 문화권을 지정하는 개체를 전달할 수 있습니다. 해당 속성은 NumberFormat 서식 정보를 제공합니다.

  • 사용자 지정 IFormatProvider 구현을 전달할 수 있습니다. 해당 메서드는 GetFormat 서식 정보를 제공하는 개체를 NumberFormatInfo 인스턴스화하고 반환해야 합니다.

nullNumberFormatInfo 경우 provider 현재 문화권에 대한 문화권이 사용됩니다.

추가 정보

적용 대상

Parse(ReadOnlySpan<Char>, IFormatProvider)

Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs

문자 범위를 값으로 구문 분석합니다.

public:
 static System::UInt32 Parse(ReadOnlySpan<char> s, IFormatProvider ^ provider) = ISpanParsable<System::UInt32>::Parse;
public static uint Parse(ReadOnlySpan<char> s, IFormatProvider? provider);
static member Parse : ReadOnlySpan<char> * IFormatProvider -> uint32
Public Shared Function Parse (s As ReadOnlySpan(Of Char), provider As IFormatProvider) As UInteger

매개 변수

s
ReadOnlySpan<Char>

구문 분석할 문자의 범위입니다.

provider
IFormatProvider

에 대한 문화권별 서식 정보를 제공하는 개체입니다 s.

반환

구문 분석의 결과입니다 s.

구현

적용 대상

Parse(ReadOnlySpan<Byte>, IFormatProvider)

Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs

UTF-8 문자의 범위를 값으로 구문 분석합니다.

public:
 static System::UInt32 Parse(ReadOnlySpan<System::Byte> utf8Text, IFormatProvider ^ provider) = IUtf8SpanParsable<System::UInt32>::Parse;
public static uint Parse(ReadOnlySpan<byte> utf8Text, IFormatProvider? provider);
static member Parse : ReadOnlySpan<byte> * IFormatProvider -> uint32
Public Shared Function Parse (utf8Text As ReadOnlySpan(Of Byte), provider As IFormatProvider) As UInteger

매개 변수

utf8Text
ReadOnlySpan<Byte>

구문 분석할 UTF-8 문자의 범위입니다.

provider
IFormatProvider

에 대한 문화권별 서식 정보를 제공하는 개체입니다 utf8Text.

반환

구문 분석의 결과입니다 utf8Text.

구현

적용 대상

Parse(String)

Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs

Important

이 API는 CLS 규격이 아닙니다.

CLS 대체 규격
System.Int64.Parse(String)

숫자의 문자열 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

public:
 static System::UInt32 Parse(System::String ^ s);
[System.CLSCompliant(false)]
public static uint Parse(string s);
public static uint Parse(string s);
[<System.CLSCompliant(false)>]
static member Parse : string -> uint32
static member Parse : string -> uint32
Public Shared Function Parse (s As String) As UInteger

매개 변수

s
String

변환할 숫자를 나타내는 문자열입니다.

반환

에 포함된 s숫자에 해당하는 32비트 부호 없는 정수입니다.

특성

예외

매개 변수는 s .입니다 null.

s 매개 변수가 올바른 형식이 아닙니다.

매개 변수는 sUInt32.MinValue 보다 작거나 UInt32.MaxValue보다 큰 숫자를 나타냅니다.

예제

다음 예제에서는 메서드를 Parse(String) 사용하여 문자열 값 배열을 구문 분석합니다.

string[] values = { "+13230", "-0", "1,390,146", "$190,235,421,127",
                    "0xFA1B", "163042", "-10", "2147483648", 
                    "14065839182", "16e07", "134985.0", "-12034" };
foreach (string value in values)
{
   try {
      uint number = UInt32.Parse(value); 
      Console.WriteLine("{0} --> {1}", value, number);
   }
   catch (FormatException) {
      Console.WriteLine("{0}: Bad Format", value);
   }   
   catch (OverflowException) {
      Console.WriteLine("{0}: Overflow", value);   
   }  
}
// The example displays the following output:
//       +13230 --> 13230
//       -0 --> 0
//       1,390,146: Bad Format
//       $190,235,421,127: Bad Format
//       0xFA1B: Bad Format
//       163042 --> 163042
//       -10: Overflow
//       2147483648 --> 2147483648
//       14065839182: Overflow
//       16e07: Bad Format
//       134985.0: Bad Format
//       -12034: Overflow
open System

let values = 
    [| "+13230"; "-0"; "1,390,146"; "$190,235,421,127"
       "0xFA1B"; "163042"; "-10"; "2147483648"
       "14065839182"; "16e07"; "134985.0"; "-12034" |]

for value in values do
    try
        let number = UInt32.Parse value 
        printfn $"{value} --> {number}"
    with
    | :? FormatException ->
        printfn $"{value}: Bad Format"
    | :? OverflowException ->
        printfn $"{value}: Overflow"
// The example displays the following output:
//       +13230 --> 13230
//       -0 --> 0
//       1,390,146: Bad Format
//       $190,235,421,127: Bad Format
//       0xFA1B: Bad Format
//       163042 --> 163042
//       -10: Overflow
//       2147483648 --> 2147483648
//       14065839182: Overflow
//       16e07: Bad Format
//       134985.0: Bad Format
//       -12034: Overflow
Dim values() As String = { "+13230", "-0", "1,390,146", "$190,235,421,127", 
                           "0xFA1B", "163042", "-10", "2147483648",  
                           "14065839182", "16e07", "134985.0", "-12034" }
For Each value As String In values
   Try
      Dim number As UInteger = UInt32.Parse(value) 
      Console.WriteLine("{0} --> {1}", value, number)
   Catch e As FormatException
      Console.WriteLine("{0}: Bad Format", value)
   Catch e As OverflowException
      Console.WriteLine("{0}: Overflow", value)   
   End Try  
Next
' The example displays the following output:
'       +13230 --> 13230
'       -0 --> 0
'       1,390,146: Bad Format
'       $190,235,421,127: Bad Format
'       0xFA1B: Bad Format
'       163042 --> 163042
'       -10: Overflow
'       2147483648 --> 2147483648
'       14065839182: Overflow
'       16e07: Bad Format
'       134985.0: Bad Format
'       -12034: Overflow

설명

매개 변수는 s 다음 형식의 숫자 문자열 표현이어야 합니다.

[ws][sign]digits[ws]

대괄호([ 및 ])의 요소는 선택 사항입니다. 다음 표에서는 각 요소에 대해 설명합니다.

요소 묘사
ws 선택적 공백입니다.
서명 선택적 기호입니다. 유효한 부호 문자는 현재 문화권의 NumberFormatInfo.NegativeSign 속성과 NumberFormatInfo.PositiveSign 속성에 따라 결정됩니다. 그러나 음수 기호는 0으로만 사용할 수 있습니다. 그렇지 않으면 메서드가 .를 OverflowExceptionthrow합니다.
자리 0에서 9 사이의 숫자 시퀀스입니다. 선행 0은 무시됩니다.

메모

매개 변수에 지정된 s 문자열은 스타일을 사용하여 해석됩니다 NumberStyles.Integer . 그룹 구분 기호 또는 소수 구분 기호를 포함할 수 없으며 소수 부분을 가질 수 없습니다.

매개 변수는 s 현재 시스템 문화권에 대해 초기화된 개체의 System.Globalization.NumberFormatInfo 서식 정보를 사용하여 구문 분석됩니다. 자세한 내용은 NumberFormatInfo.CurrentInfo를 참조하세요. 특정 문화권의 서식 정보를 사용하여 문자열을 구문 분석하려면 이 메서드를 Parse(String, IFormatProvider) 사용합니다.

추가 정보

적용 대상

Parse(String, NumberStyles)

Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs
Source:
UInt32.cs

Important

이 API는 CLS 규격이 아닙니다.

CLS 대체 규격
System.Int64.Parse(String)

지정된 스타일의 숫자 문자열 표현을 해당하는 32비트 부호 없는 정수로 변환합니다.

public:
 static System::UInt32 Parse(System::String ^ s, System::Globalization::NumberStyles style);
[System.CLSCompliant(false)]
public static uint Parse(string s, System.Globalization.NumberStyles style);
public static uint Parse(string s, System.Globalization.NumberStyles style);
[<System.CLSCompliant(false)>]
static member Parse : string * System.Globalization.NumberStyles -> uint32
static member Parse : string * System.Globalization.NumberStyles -> uint32
Public Shared Function Parse (s As String, style As NumberStyles) As UInteger

매개 변수

s
String

변환할 숫자를 나타내는 문자열입니다. 문자열은 매개 변수로 지정된 스타일을 사용하여 해석됩니다 style .

style
NumberStyles

허용되는 형식을 지정하는 열거형 값의 비트 조합입니다 s. 지정하는 일반적인 값은 .입니다 Integer.

반환

에 지정된 수에 해당하는 부호 없는 32비트 정수입니다 s.

특성

예외

snull입니다.

style가 값이 아닌 경우 NumberStyles

-또는-

style은 값과 HexNumber 값의 조합이 AllowHexSpecifier 아닙니다.

s 가 .와 호환 style되는 형식이 아닌 경우

sUInt32.MinValue 보다 작거나 UInt32.MaxValue보다 큰 숫자를 나타냅니다.

-또는-

s 에는 0이 아닌 소수 자릿수가 포함됩니다.

예제

다음 예제에서는 여러 값을 사용하여 문자열 배열의 NumberStyles 각 요소를 구문 분석하려고 합니다.

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      string[] values= { " 214309 ", "1,064,181", "(0)", "10241+", " + 21499 ", 
                         " +21499 ", "122153.00", "1e03ff", "91300.0e-2" };
      NumberStyles whitespace =  NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite;
      NumberStyles[] styles= { NumberStyles.None, whitespace, 
                               NumberStyles.AllowLeadingSign | NumberStyles.AllowTrailingSign | whitespace, 
                               NumberStyles.AllowThousands | NumberStyles.AllowCurrencySymbol, 
                               NumberStyles.AllowExponent | NumberStyles.AllowDecimalPoint };

      // Attempt to convert each number using each style combination.
      foreach (string value in values)
      {
         Console.WriteLine("Attempting to convert '{0}':", value);
         foreach (NumberStyles style in styles)
         {
            try {
               uint number = UInt32.Parse(value, style);
               Console.WriteLine("   {0}: {1}", style, number);
            }   
            catch (FormatException) {
               Console.WriteLine("   {0}: Bad Format", style);
            }   
            catch (OverflowException)
            {
               Console.WriteLine("   {0}: Overflow", value);         
            }         
         }
         Console.WriteLine();
      }
   }
}
// The example displays the following output:
//    Attempting to convert ' 214309 ':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: 214309
//       Integer, AllowTrailingSign: 214309
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '1,064,181':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: 1064181
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '(0)':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '10241+':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: 10241
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert ' + 21499 ':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert ' +21499 ':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: 21499
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '122153.00':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: 122153
//    
//    Attempting to convert '1e03ff':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '91300.0e-2':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: 913
open System
open System.Globalization

let values = 
    [| " 214309 "; "1,064,181"; "(0)"; "10241+"; " + 21499 " 
       " +21499 "; "122153.00"; "1e03ff"; "91300.0e-2" |]

let whitespace =  NumberStyles.AllowLeadingWhite ||| NumberStyles.AllowTrailingWhite
let styles = 
    [| NumberStyles.None; whitespace 
       NumberStyles.AllowLeadingSign ||| NumberStyles.AllowTrailingSign ||| whitespace
       NumberStyles.AllowThousands ||| NumberStyles.AllowCurrencySymbol
       NumberStyles.AllowExponent ||| NumberStyles.AllowDecimalPoint |]

// Attempt to convert each number using each style combination.
for value in values do
    printfn $"Attempting to convert '{value}':"
    for style in styles do
        try
            let number = UInt32.Parse(value, style)
            printfn $"   {style}: {number}"
        with
        | :? FormatException ->
            printfn $"   {style}: Bad Format"
        | :? OverflowException ->
            printfn $"   {value}: Overflow"
    printfn "" 
// The example displays the following output:
//    Attempting to convert ' 214309 ':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: 214309
//       Integer, AllowTrailingSign: 214309
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '1,064,181':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: 1064181
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '(0)':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '10241+':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: 10241
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert ' + 21499 ':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert ' +21499 ':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: 21499
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '122153.00':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: 122153
//    
//    Attempting to convert '1e03ff':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: Bad Format
//    
//    Attempting to convert '91300.0e-2':
//       None: Bad Format
//       AllowLeadingWhite, AllowTrailingWhite: Bad Format
//       Integer, AllowTrailingSign: Bad Format
//       AllowThousands, AllowCurrencySymbol: Bad Format
//       AllowDecimalPoint, AllowExponent: 913
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim values() As String = { " 214309 ", "1,064,181", "(0)", "10241+", _
                                 " + 21499 ", " +21499 ", "122153.00", _
                                 "1e03ff", "91300.0e-2" }
      Dim whitespace As NumberStyles =  NumberStyles.AllowLeadingWhite Or NumberStyles.AllowTrailingWhite
      Dim styles() As NumberStyles = { NumberStyles.None, _
                                       whitespace, _
                                       NumberStyles.AllowLeadingSign Or NumberStyles.AllowTrailingSign Or whitespace, _
                                       NumberStyles.AllowThousands Or NumberStyles.AllowCurrencySymbol, _
                                       NumberStyles.AllowExponent Or NumberStyles.AllowDecimalPoint }

      ' Attempt to convert each number using each style combination.
      For Each value As String In values
         Console.WriteLine("Attempting to convert '{0}':", value)
         For Each style As NumberStyles In styles
            Try
               Dim number As UInteger = UInt32.Parse(value, style)
               Console.WriteLine("   {0}: {1}", style, number)
            Catch e As FormatException
               Console.WriteLine("   {0}: Bad Format", style)
            Catch e As OverflowException
               Console.WriteLine("   {0}: Overflow", value)         
            End Try         
         Next
         Console.WriteLine()
      Next
   End Sub
End Module
' The example displays the following output:
'    Attempting to convert ' 214309 ':
'       None: Bad Format
'       AllowLeadingWhite, AllowTrailingWhite: 214309
'       Integer, AllowTrailingSign: 214309
'       AllowThousands, AllowCurrencySymbol: Bad Format
'       AllowDecimalPoint, AllowExponent: Bad Format
'    
'    Attempting to convert '1,064,181':
'       None: Bad Format
'       AllowLeadingWhite, AllowTrailingWhite: Bad Format
'       Integer, AllowTrailingSign: Bad Format
'       AllowThousands, AllowCurrencySymbol: 1064181
'       AllowDecimalPoint, AllowExponent: Bad Format
'    
'    Attempting to convert '(0)':
'       None: Bad Format
'       AllowLeadingWhite, AllowTrailingWhite: Bad Format
'       Integer, AllowTrailingSign: Bad Format
'       AllowThousands, AllowCurrencySymbol: Bad Format
'       AllowDecimalPoint, AllowExponent: Bad Format
'    
'    Attempting to convert '10241+':
'       None: Bad Format
'       AllowLeadingWhite, AllowTrailingWhite: Bad Format
'       Integer, AllowTrailingSign: 10241
'       AllowThousands, AllowCurrencySymbol: Bad Format
'       AllowDecimalPoint, AllowExponent: Bad Format
'    
'    Attempting to convert ' + 21499 ':
'       None: Bad Format
'       AllowLeadingWhite, AllowTrailingWhite: Bad Format
'       Integer, AllowTrailingSign: Bad Format
'       AllowThousands, AllowCurrencySymbol: Bad Format
'       AllowDecimalPoint, AllowExponent: Bad Format
'    
'    Attempting to convert ' +21499 ':
'       None: Bad Format
'       AllowLeadingWhite, AllowTrailingWhite: Bad Format
'       Integer, AllowTrailingSign: 21499
'       AllowThousands, AllowCurrencySymbol: Bad Format
'       AllowDecimalPoint, AllowExponent: Bad Format
'    
'    Attempting to convert '122153.00':
'       None: Bad Format
'       AllowLeadingWhite, AllowTrailingWhite: Bad Format
'       Integer, AllowTrailingSign: Bad Format
'       AllowThousands, AllowCurrencySymbol: Bad Format
'       AllowDecimalPoint, AllowExponent: 122153
'    
'    Attempting to convert '1e03ff':
'       None: Bad Format
'       AllowLeadingWhite, AllowTrailingWhite: Bad Format
'       Integer, AllowTrailingSign: Bad Format
'       AllowThousands, AllowCurrencySymbol: Bad Format
'       AllowDecimalPoint, AllowExponent: Bad Format
'    
'    Attempting to convert '91300.0e-2':
'       None: Bad Format
'       AllowLeadingWhite, AllowTrailingWhite: Bad Format
'       Integer, AllowTrailingSign: Bad Format
'       AllowThousands, AllowCurrencySymbol: Bad Format
'       AllowDecimalPoint, AllowExponent: 913

설명

매개 변수는 style 구문 분석 작업이 성공하기 위해 매개 변수에 허용되는 s 스타일 요소(예: 공백, 양수 또는 음수 기호, 그룹 구분 기호 또는 소수점 기호)를 정의합니다. style 는 열거형의 비트 플래그 NumberStyles 조합이어야 합니다. 이 매개 변수는 style 16진수 값의 문자열 표현을 포함하는 경우 s , 런타임에만 표시되는 s 숫자 시스템(10진수 또는 16진수)을 알려 주거나 공백 또는 기호를 s허용하지 않으려는 경우에 이 메서드 오버로드를 유용하게 만듭니다.

style에 따라 매개 변수에는 s 다음 요소가 포함될 수 있습니다.

[ws][$][sign][digits,]digits[.fractional_digits][E[sign]exponential_digits][ws]

대괄호([ 및 ])의 요소는 선택 사항입니다. 포함된 style경우 NumberStyles.AllowHexSpecifier 매개 변수에 s 다음 요소가 포함될 수 있습니다.

[ws]hexdigits[ws]

다음 표에서는 각 요소에 대해 설명합니다.

요소 묘사
ws 선택적 공백입니다. 플래그가 포함된 경우 시작 s 부분에 공백이 style 표시될 수 있으며 플래그가 포함된 NumberStyles.AllowLeadingWhite 경우 s 끝에 style 표시될 수 NumberStyles.AllowTrailingWhite 있습니다.
$ 문화권별 통화 기호입니다. 문자열의 위치는 현재 문화권의 NumberFormatInfo.CurrencyNegativePattern 속성 및 NumberFormatInfo.CurrencyPositivePattern 속성에 의해 정의됩니다. 플래그가 포함된 경우 s 현재 문화권의 통화 기호가 styleNumberStyles.AllowCurrencySymbol 나타날 수 있습니다.
서명 선택적 기호입니다. 플래그가 포함된 경우 시작 s 부분에 표시할 수 있으며 플래그가 포함된 style 경우 NumberStyles.AllowLeadingSign 끝에 s 표시할 수 style 있습니다.NumberStyles.AllowTrailingSign 플래그를 포함하는 s 경우 style 괄호를 사용하여 NumberStyles.AllowParentheses 음수 값을 나타낼 수 있습니다. 그러나 음수 기호는 0으로만 사용할 수 있습니다. 그렇지 않으면 메서드가 .를 OverflowExceptionthrow합니다.
자리

fractional_digits

exponential_digits
0에서 9까지의 숫자 시퀀스입니다. fractional_digits 경우 숫자 0만 유효합니다.
, 문화권별 그룹 구분 기호입니다. 플래그가 포함된 경우 s 현재 문화권의 그룹 구분 기호가 styleNumberStyles.AllowThousands 나타날 수 있습니다.
. 문화권별 소수점 기호입니다. 플래그가 포함된 경우 s 현재 문화권의 소수점 기호가 styleNumberStyles.AllowDecimalPoint 나타날 수 있습니다. 구문 분석 작업이 성공하려면 숫자 0만 소수 자릿수로 표시할 수 있습니다. fractional_digits 다른 숫자가 포함되어 있으면 throw FormatException 됩니다.
E 값이 지수(과학적) 표기법으로 표현됨을 나타내는 "e" 또는 "E" 문자입니다. 플래그를 포함하는 경우 s 매개 변수는 style 지수 표기법으로 NumberStyles.AllowExponent 숫자를 나타낼 수 있습니다.
hexdigits 0부터 f까지의 16진수 숫자 또는 0부터 F까지의 시퀀스입니다.

메모

인수 값 s 에 관계없이 구문 분석 작업에서 style 종료되는 NUL(U+0000) 문자는 무시됩니다.

숫자만 있는 문자열(스타일에 NumberStyles.None 해당)은 형식 범위에 UInt32 있는 경우 항상 성공적으로 구문 분석됩니다. 나머지 NumberStyles 멤버의 대부분은 입력 문자열에 존재할 수 있지만 존재할 필요는 없는 요소를 제어합니다. 다음 표에서는 개별 NumberStyles 멤버가 에 있을 s수 있는 요소에 미치는 영향을 나타냅니다.

NumberStyles 숫자 외에 s 허용되는 요소
None digits 요소만 해당합니다.
AllowDecimalPoint 소수점(.) 및 소수 자릿수 요소입니다 .
AllowExponent exponential_digits 함께 지수 표기법을 나타내는 "e" 또는 "E" 문자입니다.
AllowLeadingWhite 의 시작 부분에 있는 ws 요소입니다 s.
AllowTrailingWhite 의 끝에 있는 ws 요소입니다 s.
AllowLeadingSign 의 시작 부분에 있는 기호 요소입니다 s.
AllowTrailingSign 의 끝에 있는 sign 요소입니다 s.
AllowParentheses 숫자 값을 묶는 괄호 형식의 기호 요소입니다.
AllowThousands 그룹 구분 기호(,) 요소입니다.
AllowCurrencySymbol 통화($) 요소입니다.
Currency 모든 요소. 그러나 s 16진수 또는 지수 표기법의 숫자를 나타낼 수는 없습니다.
Float 시작 또는 끝에 있는 s 요소, 시작 부분에 s 및 소수점(.) 기호입니다. 매개 변수는 s 지수 표기법을 사용할 수도 있습니다.
Number , 그룹 구분 기호(ws) 및 소수점(sign) 요소입니다.
Any 모든 요소. 그러나 s 16진수를 나타낼 수는 없습니다.

특정 스타일 요소를 NumberStyless 허용하지만 필요하지 않은 다른 NumberStyles.AllowHexSpecifier 값과 달리 스타일 값은 개별 숫자 문자가 항상 16진수 문자 s 로 해석됨을 의미합니다. 유효한 16진수 문자는 0-9, A-F 및 a-f입니다. "0x"와 같은 접두사는 허용되지 않습니다. 매개 변수와 style 결합할 수 있는 다른 플래그는 다음과 NumberStyles.AllowLeadingWhite같습니다NumberStyles.AllowTrailingWhite. (열거형에는 NumberStyles 공백 플래그를 모두 포함하는 복합 숫자 스타일 NumberStyles.HexNumber이 포함됩니다.)

매개 변수와 style 결합할 수 있는 다른 플래그는 다음과 NumberStyles.AllowLeadingWhite같습니다NumberStyles.AllowTrailingWhite. (열거형에는 NumberStyles 공백 플래그를 모두 포함하는 복합 숫자 스타일 NumberStyles.HexNumber이 포함됩니다.)

메모

16진수의 문자열 표현인 경우 s 16진수로 구분하는 데코레이션(예: 0x 또는 &h)이 앞에 올 수 없습니다. 이렇게 하면 변환이 실패합니다.

매개 변수는 s 현재 시스템 문화권에 대해 초기화된 개체의 NumberFormatInfo 서식 정보를 사용하여 구문 분석됩니다. 구문 분석 작업에 서식 정보가 사용되는 문화권을 지정하려면 오버로드를 Parse(String, NumberStyles, IFormatProvider) 호출합니다.

추가 정보

적용 대상