Enum.Parse 메서드

정의

하나 이상의 열거된 상수의 이름이나 숫자 값의 문자열 표현을 해당하는 열거형 개체로 변환합니다.

오버로드

Parse(Type, ReadOnlySpan<Char>)

하나 이상의 열거형 상수의 이름 또는 숫자 값의 문자 표현 범위를 해당하는 열거형 개체로 변환합니다.

Parse(Type, String)

하나 이상의 열거된 상수의 이름이나 숫자 값의 문자열 표현을 해당하는 열거형 개체로 변환합니다.

Parse(Type, ReadOnlySpan<Char>, Boolean)

하나 이상의 열거형 상수의 이름 또는 숫자 값의 문자 표현 범위를 해당하는 열거형 개체로 변환합니다. 매개 변수는 연산이 대/소문자를 구분하지 않는지를 지정합니다.

Parse(Type, String, Boolean)

하나 이상의 열거된 상수의 이름이나 숫자 값의 문자열 표현을 해당하는 열거형 개체로 변환합니다. 매개 변수는 연산이 대/소문자를 구분하지 않는지를 지정합니다.

Parse<TEnum>(String, Boolean)

TEnum에 의해 하나 이상의 열거된 상수의 이름이나 숫자 값의 문자열 표현을 해당하는 열거형 개체로 변환합니다. 매개 변수는 연산이 대/소문자를 구분하지 않는지를 지정합니다.

Parse<TEnum>(ReadOnlySpan<Char>, Boolean)

에 지정된 TEnum 하나 이상의 열거형 상수의 이름 또는 숫자 값의 문자 표현 범위를 해당하는 열거형 개체로 변환합니다. 매개 변수는 연산이 대/소문자를 구분하지 않는지를 지정합니다.

Parse<TEnum>(ReadOnlySpan<Char>)

에 지정된 TEnum 하나 이상의 열거형 상수의 이름 또는 숫자 값의 문자 표현 범위를 해당하는 열거형 개체로 변환합니다.

Parse<TEnum>(String)

TEnum에 의해 하나 이상의 열거된 상수의 이름이나 숫자 값의 문자열 표현을 해당하는 열거형 개체로 변환합니다.

Parse(Type, ReadOnlySpan<Char>)

Source:
Enum.cs
Source:
Enum.cs
Source:
Enum.cs

하나 이상의 열거형 상수의 이름 또는 숫자 값의 문자 표현 범위를 해당하는 열거형 개체로 변환합니다.

public:
 static System::Object ^ Parse(Type ^ enumType, ReadOnlySpan<char> value);
public static object Parse (Type enumType, ReadOnlySpan<char> value);
static member Parse : Type * ReadOnlySpan<char> -> obj
Public Shared Function Parse (enumType As Type, value As ReadOnlySpan(Of Char)) As Object

매개 변수

enumType
Type

열거형 형식입니다.

value
ReadOnlySpan<Char>

변환할 이름 또는 값을 포함하는 범위입니다.

반환

값이 value로 표현된 enumType 형식의 개체입니다.

예외

enumType이(가) null인 경우

enumTypeEnum이 아닌 경우

value가 빈 문자열("")이거나 공백만 포함합니다.

value 는 이름이지만 열거형에 정의된 명명된 상수 중 하나가 아닙니다.

valueenumType의 내부 형식 범위를 벗어납니다.

.NET 8 이상 버전: enumType 부울 지원 열거형 형식입니다.

적용 대상

Parse(Type, String)

Source:
Enum.cs
Source:
Enum.cs
Source:
Enum.cs

하나 이상의 열거된 상수의 이름이나 숫자 값의 문자열 표현을 해당하는 열거형 개체로 변환합니다.

public:
 static System::Object ^ Parse(Type ^ enumType, System::String ^ value);
public static object Parse (Type enumType, string value);
[System.Runtime.InteropServices.ComVisible(true)]
public static object Parse (Type enumType, string value);
static member Parse : Type * string -> obj
[<System.Runtime.InteropServices.ComVisible(true)>]
static member Parse : Type * string -> obj
Public Shared Function Parse (enumType As Type, value As String) As Object

매개 변수

enumType
Type

열거형 형식입니다.

value
String

변환할 이름이나 값이 포함된 문자열입니다.

반환

값이 value로 표현된 enumType 형식의 개체입니다.

특성

예외

enumType 또는 valuenull인 경우

enumTypeEnum이 아닌 경우

또는

value가 빈 문자열("")이거나 공백만 포함합니다.

또는

value 는 이름이지만 열거형에 정의된 명명된 상수 중 하나가 아닙니다.

valueenumType의 내부 형식 범위를 벗어납니다.

.NET 8 이상 버전: enumType 부울 지원 열거형 형식입니다.

예제

다음 예제에서는 메서드를 Parse(Type, String) 사용하여 메서드를 호출하여 만든 문자열 배열을 GetNames 구문 분석합니다. 또한 메서드를 Parse(Type, String) 사용하여 비트 필드로 구성된 열거형 값을 구문 분석합니다.

using namespace System;

[Flags]
enum class Colors
{
   Red = 1,
   Green = 2,
   Blue = 4,
   Yellow = 8
};

int main()
{
   Console::WriteLine(  "The entries of the Colors enumeration are:" );
   Array^ a = Enum::GetNames( Colors::typeid );
   Int32 i = 0;
   while ( i < a->Length )
   {
      Object^ o = a->GetValue( i );
      Console::WriteLine( o->ToString() );
      i++;
   }

   Console::WriteLine();
   Object^ orange = Enum::Parse( Colors::typeid,  "Red, Yellow" );
   Console::WriteLine("The orange value has the combined entries of {0}", orange );
}

/*
This code example produces the following results:

The entries of the Colors Enum are:
Red
Green
Blue
Yellow

The orange value has the combined entries of Red, Yellow

*/
using System;

public class ParseTest
{
    [Flags]
    enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };

    public static void Main()
    {
        Console.WriteLine("The entries of the Colors enumeration are:");
        foreach (string colorName in Enum.GetNames(typeof(Colors)))
        {
            Console.WriteLine("{0} = {1:D}", colorName,
                                         Enum.Parse(typeof(Colors), colorName));
        }
        Console.WriteLine();

        Colors orange = (Colors) Enum.Parse(typeof(Colors), "Red, Yellow");
        Console.WriteLine("The orange value {0:D} has the combined entries of {0}",
                           orange);
    }
}

/*
This code example produces the following results:

The entries of the Colors Enum are:
Red = 1
Green = 2
Blue = 4
Yellow = 8

The orange value 9 has the combined entries of Red, Yellow

*/
open System

[<Flags>]
type Colors =
    | Red = 1
    | Green = 2
    | Blue = 4
    | Yellow = 8

printfn "The entries of the Colors enumeration are:"
for colorName in Enum.GetNames typeof<Colors> do
    printfn $"{colorName} = {Enum.Parse(typeof<Colors>, colorName):D}"
printfn ""

let orange = Enum.Parse(typeof<Colors>, "Red, Yellow") :?> Colors
printfn $"The orange value {orange:D} has the combined entries of {orange}"

// This code example produces the following results:
//     The entries of the Colors Enum are:
//     Red = 1
//     Green = 2
//     Blue = 4
//     Yellow = 8
//    
//     The orange value 9 has the combined entries of Red, Yellow
Public Class ParseTest

    <Flags()> _
    Enum Colors
        Red = 1
        Green = 2
        Blue = 4
        Yellow = 8
    End Enum

    Public Shared Sub Main()
        Console.WriteLine("The entries of the Colors enumeration are:")
        Dim colorName As String
        For Each colorName In [Enum].GetNames(GetType(Colors))
            Console.WriteLine("{0} = {1:D}", colorName, [Enum].Parse(GetType(Colors), colorName))
        Next
        Console.WriteLine()

        Dim orange As Colors = CType([Enum].Parse(GetType(Colors), "Red, Yellow"), Colors)
        Console.WriteLine("The orange value {0:D} has the combined entries of {0}", orange)
    End Sub
End Class

'This example displays the following output:
'
'The entries of the Colors Enum are:
'Red = 1
'Green = 2
'Blue = 4
'Yellow = 8
'
'The myOrange value 9 has the combined entries of Red, Yellow
'

설명

매개 변수에는 value 열거형 멤버의 기본 값 또는 명명된 상수의 문자열 표현 또는 쉼표(,)로 구분된 명명된 상수 목록이 포함됩니다. 하나 이상의 빈 공백이 의 각 값, 이름 또는 쉼표 value앞에 오거나 따를 수 있습니다. 가 목록인 경우 value 반환 값은 비트 OR 연산과 결합된 지정된 이름의 값입니다.

가 의 명명된 상수enumType에 해당하지 않는 이름인 경우 value 메서드는 을 ArgumentExceptionthrow합니다. 가 열거형의 기본 값을 나타내지 않는 정수의 enumType 문자열 표현인 경우 value 메서드는 기본 값이 정수 형식으로 변환되는 value 열거형 멤버를 반환합니다. 이 동작이 바람직하지 않은 경우 메서드를 IsDefined 호출하여 정수의 특정 문자열 표현이 실제로 의 enumType멤버인지 확인합니다. 다음 예제에서는 열거형을 Colors 정의하고, 메서드를 호출 Parse(Type, String) 하여 문자열을 해당 열거형 값으로 변환하고, 메서드를 호출 IsDefined 하여 특정 정수 값이 열거형의 Colors 기본 값인지 확인합니다.

using System;

[Flags] enum Colors { None=0, Red = 1, Green = 2, Blue = 4 };

public class Example
{
   public static void Main()
   {
      string[] colorStrings = { "0", "2", "8", "blue", "Blue", "Yellow", "Red, Green" };
      foreach (string colorString in colorStrings)
      {
         try {
            Colors colorValue = (Colors) Enum.Parse(typeof(Colors), colorString);
            if (Enum.IsDefined(typeof(Colors), colorValue) | colorValue.ToString().Contains(","))
               Console.WriteLine("Converted '{0}' to {1}.", colorString, colorValue.ToString());
            else
               Console.WriteLine("{0} is not an underlying value of the Colors enumeration.", colorString);
         }
         catch (ArgumentException) {
            Console.WriteLine("'{0}' is not a member of the Colors enumeration.", colorString);
         }
      }
   }
}
// The example displays the following output:
//       Converted '0' to None.
//       Converted '2' to Green.
//       8 is not an underlying value of the Colors enumeration.
//       'blue' is not a member of the Colors enumeration.
//       Converted 'Blue' to Blue.
//       'Yellow' is not a member of the Colors enumeration.
//       Converted 'Red, Green' to Red, Green.
open System

[<Flags>]
type Colors =
    | None = 0
    | Red = 1
    | Green = 2
    | Blue = 4

let colorStrings = [ "0"; "2"; "8"; "blue"; "Blue"; "Yellow"; "Red, Green" ]
for colorString in colorStrings do
    try
        let colorValue = Enum.Parse(typeof<Colors>, colorString) :?> Colors
        if Enum.IsDefined(typeof<Colors>, colorValue) || (string colorValue).Contains "," then
            printfn $"Converted '{colorString}' to {colorValue}."
        else
            printfn $"{colorString} is not an underlying value of the Colors enumeration."
    with :? ArgumentException ->
        printfn $"'{colorString}' is not a member of the Colors enumeration."
// The example displays the following output:
//       Converted '0' to None.
//       Converted '2' to Green.
//       8 is not an underlying value of the Colors enumeration.
//       'blue' is not a member of the Colors enumeration.
//       Converted 'Blue' to Blue.
//       'Yellow' is not a member of the Colors enumeration.
//       Converted 'Red, Green' to Red, Green.
<Flags> Enum Colors As Integer
   None = 0
   Red = 1
   Green = 2
   Blue = 4
End Enum

Module Example
   Public Sub Main()
      Dim colorStrings() As String = {"0", "2", "8", "blue", "Blue", "Yellow", "Red, Green"}
      For Each colorString As String In colorStrings
         Try
            Dim colorValue As Colors = CType([Enum].Parse(GetType(Colors), colorString), Colors)        
            If [Enum].IsDefined(GetType(Colors), colorValue) Or colorValue.ToString().Contains(",") Then 
               Console.WriteLine("Converted '{0}' to {1}.", colorString, colorValue.ToString())
            Else
               Console.WriteLine("{0} is not an underlying value of the Colors enumeration.", colorString)            
            End If                    
         Catch e As ArgumentException
            Console.WriteLine("'{0}' is not a member of the Colors enumeration.", colorString)
         End Try
      Next
   End Sub
End Module
' The example displays the following output:
'       Converted '0' to None.
'       Converted '2' to Green.
'       8 is not an underlying value of the Colors enumeration.
'       'blue' is not a member of the Colors enumeration.
'       Converted 'Blue' to Blue.
'       'Yellow' is not a member of the Colors enumeration.
'       Converted 'Red, Green' to Red, Green.

이 작업은 대/소문자를 구분합니다.

추가 정보

적용 대상

Parse(Type, ReadOnlySpan<Char>, Boolean)

Source:
Enum.cs
Source:
Enum.cs
Source:
Enum.cs

하나 이상의 열거형 상수의 이름 또는 숫자 값의 문자 표현 범위를 해당하는 열거형 개체로 변환합니다. 매개 변수는 연산이 대/소문자를 구분하지 않는지를 지정합니다.

public:
 static System::Object ^ Parse(Type ^ enumType, ReadOnlySpan<char> value, bool ignoreCase);
public static object Parse (Type enumType, ReadOnlySpan<char> value, bool ignoreCase);
static member Parse : Type * ReadOnlySpan<char> * bool -> obj
Public Shared Function Parse (enumType As Type, value As ReadOnlySpan(Of Char), ignoreCase As Boolean) As Object

매개 변수

enumType
Type

열거형 형식입니다.

value
ReadOnlySpan<Char>

변환할 이름 또는 값을 포함하는 범위입니다.

ignoreCase
Boolean

대/소문자를 무시하는 경우 true이고, 구분하는 경우 false입니다.

반환

값이 value로 표현된 enumType 형식의 개체입니다.

예외

enumType이(가) null인 경우

enumTypeEnum이 아닌 경우

value가 빈 문자열("")이거나 공백만 포함합니다.

value 는 이름이지만 열거형에 정의된 명명된 상수 중 하나가 아닙니다.

value 가 의 기본 형식 범위를 벗어났습니다. enumType

.NET 8 이상 버전: enumType 부울 지원 열거형 형식입니다.

적용 대상

Parse(Type, String, Boolean)

Source:
Enum.cs
Source:
Enum.cs
Source:
Enum.cs

하나 이상의 열거된 상수의 이름이나 숫자 값의 문자열 표현을 해당하는 열거형 개체로 변환합니다. 매개 변수는 연산이 대/소문자를 구분하지 않는지를 지정합니다.

public:
 static System::Object ^ Parse(Type ^ enumType, System::String ^ value, bool ignoreCase);
public static object Parse (Type enumType, string value, bool ignoreCase);
[System.Runtime.InteropServices.ComVisible(true)]
public static object Parse (Type enumType, string value, bool ignoreCase);
static member Parse : Type * string * bool -> obj
[<System.Runtime.InteropServices.ComVisible(true)>]
static member Parse : Type * string * bool -> obj
Public Shared Function Parse (enumType As Type, value As String, ignoreCase As Boolean) As Object

매개 변수

enumType
Type

열거형 형식입니다.

value
String

변환할 이름이나 값이 포함된 문자열입니다.

ignoreCase
Boolean

대/소문자를 무시하는 경우 true이고, 구분하는 경우 false입니다.

반환

값이 value로 표현된 enumType 형식의 개체입니다.

특성

예외

enumType 또는 valuenull인 경우

enumTypeEnum이 아닌 경우

또는

value이(가) 빈 문자열("")이거나 공백만 포함합니다.

또는

value 는 이름이지만 열거형에 정의된 명명된 상수 중 하나가 아닙니다.

valueenumType의 내부 형식 범위를 벗어납니다.

.NET 8 이상 버전: enumType 부울 지원 열거형 형식입니다.

예제

다음 예제에서는 메서드를 Parse(Type, String, Boolean) 사용하여 메서드를 호출하여 만든 문자열 배열을 GetNames 구문 분석합니다. 또한 메서드를 Parse(Type, String) 사용하여 비트 필드로 구성된 열거형 값을 구문 분석합니다.

using System;

[Flags] enum Colors { None=0, Red = 1, Green = 2, Blue = 4 };

public class Example
{
   public static void Main()
   {
      string[] colorStrings = { "0", "2", "8", "blue", "Blue", "Yellow", "Red, Green" };
      foreach (string colorString in colorStrings)
      {
         try {
            Colors colorValue = (Colors) Enum.Parse(typeof(Colors), colorString, true);
            if (Enum.IsDefined(typeof(Colors), colorValue) | colorValue.ToString().Contains(","))
               Console.WriteLine("Converted '{0}' to {1}.", colorString, colorValue.ToString());
            else
               Console.WriteLine("{0} is not an underlying value of the Colors enumeration.", colorString);
         }
         catch (ArgumentException) {
            Console.WriteLine("{0} is not a member of the Colors enumeration.", colorString);
         }
      }
   }
}
// The example displays the following output:
//       Converted '0' to None.
//       Converted '2' to Green.
//       8 is not an underlying value of the Colors enumeration.
//       Converted 'blue' to Blue.
//       Converted 'Blue' to Blue.
//       Yellow is not a member of the Colors enumeration.
//       Converted 'Red, Green' to Red, Green.
open System

[<Flags>]
type Colors =
    | None = 0
    | Red = 1
    | Green = 2
    | Blue = 4

let colorStrings = [ "0"; "2"; "8"; "blue"; "Blue"; "Yellow"; "Red, Green" ]
for colorString in colorStrings do
    try
        let colorValue = Enum.Parse(typeof<Colors>, colorString, true) :?> Colors
        if Enum.IsDefined(typeof<Colors>, colorValue) || (string colorValue).Contains "," then
            printfn $"Converted '{colorString}' to {colorValue}."
        else
            printfn $"{colorString} is not an underlying value of the Colors enumeration."
    with :? ArgumentException ->
        printfn $"{colorString} is not a member of the Colors enumeration."

// The example displays the following output:
//       Converted '0' to None.
//       Converted '2' to Green.
//       8 is not an underlying value of the Colors enumeration.
//       Converted 'blue' to Blue.
//       Converted 'Blue' to Blue.
//       Yellow is not a member of the Colors enumeration.
//       Converted 'Red, Green' to Red, Green.
<Flags> Enum Colors As Integer
   None = 0
   Red = 1
   Green = 2
   Blue = 4
End Enum

Module Example
   Public Sub Main()
      Dim colorStrings() As String = {"0", "2", "8", "blue", "Blue", "Yellow", "Red, Green"}
      For Each colorString As String In colorStrings
         Try
            Dim colorValue As Colors = CType([Enum].Parse(GetType(Colors), colorString, True), Colors)        
            If [Enum].IsDefined(GetType(Colors), colorValue) Or colorValue.ToString().Contains(",") Then 
               Console.WriteLine("Converted '{0}' to {1}.", colorString, colorValue.ToString())
            Else
               Console.WriteLine("{0} is not an underlying value of the Colors enumeration.", colorString)            
            End If                    
         Catch e As ArgumentException
            Console.WriteLine("{0} is not a member of the Colors enumeration.", colorString)
         End Try
      Next
   End Sub
End Module
' The example displays the following output:
'       Converted '0' to None.
'       Converted '2' to Green.
'       8 is not an underlying value of the Colors enumeration.
'       Converted 'blue' to Blue.
'       Converted 'Blue' to Blue.
'       Yellow is not a member of the Colors enumeration.
'       Converted 'Red, Green' to Red, Green.

설명

매개 변수에는 value 열거형 멤버의 기본 값 또는 명명된 상수의 문자열 표현 또는 쉼표(,)로 구분된 명명된 상수 목록이 포함됩니다. 하나 이상의 빈 공백이 의 각 값, 이름 또는 쉼표 value앞에 오거나 따를 수 있습니다. 가 목록인 경우 value 반환 값은 비트 OR 연산과 결합된 지정된 이름의 값입니다.

가 의 명명된 상수enumType에 해당하지 않는 이름인 경우 value 메서드는 을 ArgumentExceptionthrow합니다. 가 열거형의 기본 값을 나타내지 않는 정수의 enumType 문자열 표현인 경우 value 메서드는 기본 값이 정수 형식으로 변환되는 value 열거형 멤버를 반환합니다. 이 동작이 바람직하지 않은 경우 메서드를 IsDefined 호출하여 정수의 특정 문자열 표현이 실제로 의 enumType멤버인지 확인합니다. 다음 예제에서는 열거형을 Colors 정의하고, 메서드를 호출 Parse(Type, String, Boolean) 하여 문자열을 해당 열거형 값으로 변환하고, 메서드를 호출 IsDefined 하여 특정 정수 값이 열거형의 Colors 기본 값인지 확인합니다.

매개 변수는 ignoreCase 이 작업이 대/소문자를 구분하는지 여부를 지정합니다.

추가 정보

적용 대상

Parse<TEnum>(String, Boolean)

Source:
Enum.cs
Source:
Enum.cs
Source:
Enum.cs

TEnum에 의해 하나 이상의 열거된 상수의 이름이나 숫자 값의 문자열 표현을 해당하는 열거형 개체로 변환합니다. 매개 변수는 연산이 대/소문자를 구분하지 않는지를 지정합니다.

public:
generic <typename TEnum>
 where TEnum : value class static TEnum Parse(System::String ^ value, bool ignoreCase);
public static TEnum Parse<TEnum> (string value, bool ignoreCase) where TEnum : struct;
static member Parse : string * bool -> 'Enum (requires 'Enum : struct)
Public Shared Function Parse(Of TEnum As Structure) (value As String, ignoreCase As Boolean) As TEnum

형식 매개 변수

TEnum

열거형 형식입니다.

매개 변수

value
String

변환할 이름이나 값이 포함된 문자열입니다.

ignoreCase
Boolean

대/소문자를 무시하는 경우 true이고, 구분하는 경우 false입니다.

반환

TEnum

값이 value로 표현된 TEnum 형식의 개체입니다.

예외

TEnumEnum 형식이 아닙니다.

value이(가) null인 경우

value에 열거형 정보가 포함되어 있지 않습니다.

.NET 8 이상 버전: TEnum 부울 지원 열거형 형식입니다.

적용 대상

Parse<TEnum>(ReadOnlySpan<Char>, Boolean)

Source:
Enum.cs
Source:
Enum.cs
Source:
Enum.cs

에 지정된 TEnum 하나 이상의 열거형 상수의 이름 또는 숫자 값의 문자 표현 범위를 해당하는 열거형 개체로 변환합니다. 매개 변수는 연산이 대/소문자를 구분하지 않는지를 지정합니다.

public:
generic <typename TEnum>
 where TEnum : value class static TEnum Parse(ReadOnlySpan<char> value, bool ignoreCase);
public static TEnum Parse<TEnum> (ReadOnlySpan<char> value, bool ignoreCase) where TEnum : struct;
static member Parse : ReadOnlySpan<char> * bool -> 'Enum (requires 'Enum : struct)
Public Shared Function Parse(Of TEnum As Structure) (value As ReadOnlySpan(Of Char), ignoreCase As Boolean) As TEnum

형식 매개 변수

TEnum

열거형 형식입니다.

매개 변수

value
ReadOnlySpan<Char>

변환할 이름 또는 값을 포함하는 범위입니다.

ignoreCase
Boolean

대/소문자를 무시하는 경우 true이고, 구분하는 경우 false입니다.

반환

TEnum

TEnum값이 로 표현되는 value형식 TEnum 의 개체입니다.

예외

TEnumEnum 형식이 아닙니다.

value에 열거형 정보가 포함되어 있지 않습니다.

.NET 8 이상 버전: TEnum 부울 지원 열거형 형식입니다.

적용 대상

Parse<TEnum>(ReadOnlySpan<Char>)

Source:
Enum.cs
Source:
Enum.cs
Source:
Enum.cs

에 지정된 TEnum 하나 이상의 열거형 상수의 이름 또는 숫자 값의 문자 표현 범위를 해당하는 열거형 개체로 변환합니다.

public:
generic <typename TEnum>
 where TEnum : value class static TEnum Parse(ReadOnlySpan<char> value);
public static TEnum Parse<TEnum> (ReadOnlySpan<char> value) where TEnum : struct;
static member Parse : ReadOnlySpan<char> -> 'Enum (requires 'Enum : struct)
Public Shared Function Parse(Of TEnum As Structure) (value As ReadOnlySpan(Of Char)) As TEnum

형식 매개 변수

TEnum

열거형 형식입니다.

매개 변수

value
ReadOnlySpan<Char>

변환할 이름 또는 값을 포함하는 범위입니다.

반환

TEnum

TEnum값이 로 표현되는 value형식 TEnum 의 개체입니다.

예외

TEnumEnum 형식이 아닙니다.

value에 열거형 정보가 포함되어 있지 않습니다.

.NET 8 이상 버전: TEnum 부울 지원 열거형 형식입니다.

적용 대상

Parse<TEnum>(String)

Source:
Enum.cs
Source:
Enum.cs
Source:
Enum.cs

TEnum에 의해 하나 이상의 열거된 상수의 이름이나 숫자 값의 문자열 표현을 해당하는 열거형 개체로 변환합니다.

public:
generic <typename TEnum>
 where TEnum : value class static TEnum Parse(System::String ^ value);
public static TEnum Parse<TEnum> (string value) where TEnum : struct;
static member Parse : string -> 'Enum (requires 'Enum : struct)
Public Shared Function Parse(Of TEnum As Structure) (value As String) As TEnum

형식 매개 변수

TEnum

열거형 형식입니다.

매개 변수

value
String

변환할 이름이나 값이 포함된 문자열입니다.

반환

TEnum

값이 value로 표현된 TEnum 형식의 개체입니다.

예외

TEnumEnum 형식이 아닙니다.

value이(가) null인 경우

value에 열거형 정보가 포함되어 있지 않습니다.

.NET 8 이상 버전: TEnum 부울 지원 열거형 형식입니다.

적용 대상