Type.IsEnum 속성

정의

Type이 열거형을 나타내는지 여부를 나타내는 값을 가져옵니다.

public:
 virtual property bool IsEnum { bool get(); };
public:
 property bool IsEnum { bool get(); };
public virtual bool IsEnum { get; }
public bool IsEnum { get; }
member this.IsEnum : bool
Public Overridable ReadOnly Property IsEnum As Boolean
Public ReadOnly Property IsEnum As Boolean

속성 값

Boolean

현재 true이 열거형을 나타내면 Type이고, 그렇지 않으면 false입니다.

구현

예제

다음 예제에서는 사용 하는 방법에 설명 합니다 IsEnum 속성입니다.

using namespace System;
enum class Color
{ Red, Blue, Green };

int main()
{
   Type^ colorType = Color::typeid;
   Type^ enumType = Enum::typeid;
   Console::WriteLine( "Is Color an enum? {0}.", colorType->IsEnum );
   Console::WriteLine( "Is Color a value type? {0}.", colorType->IsValueType );
   Console::WriteLine( "Is Enum an enum Type? {0}.", enumType->IsEnum );
   Console::WriteLine( "Is Enum a value type? {0}.", enumType->IsValueType );
}
// The example displays the following output:
//     Is Color an enum? True.
//     Is Color a value type? True.
//     Is Enum an enum type? False.
//     Is Enum a value type? False.
using System;
public enum Color
{ Red, Blue, Green }

class TestIsEnum
{
    public static void Main()
    {
       Type colorType = typeof(Color);
       Type enumType = typeof(Enum);
       Console.WriteLine("Is Color an enum? {0}.", colorType.IsEnum);
       Console.WriteLine("Is Color a value type? {0}.", colorType.IsValueType);
       Console.WriteLine("Is Enum an enum Type? {0}.", enumType.IsEnum);
       Console.WriteLine("Is Enum a value type? {0}.", enumType.IsValueType);
   }
}
// The example displays the following output:
//     Is Color an enum? True.
//     Is Color a value type? True.
//     Is Enum an enum type? False.
//     Is Enum a value type? False.
Public Enum Color
    Red
    Blue
    Green
End Enum

Class Example
   Public Shared Sub Main()
        Dim colorType As Type = GetType(Color)
        Dim enumType As Type = GetType([Enum])
        Console.WriteLine("Is Color an enum? {0}.", colorType.IsEnum)
        Console.WriteLine("Is Color a value type? {0}.", colorType.IsValueType)
        Console.WriteLine("Is Enum an enum type? {0}.", enumType.IsEnum)
        Console.WriteLine("Is Enum a value type? {0}.", enumType.IsValueType)
    End Sub 
End Class
' The example displays the following output:
'     Is Color an enum? True.
'     Is Color a value type? True.
'     Is Enum an enum type? False.
'     Is Enum a value type? False.

설명

이 속성은 true 열거형에 대해 를 반환하지만 형식 자체에는 반환하지 Enum 않습니다.

현재 가 Type 구성된 제네릭 형식을 나타내는 경우 이 속성은 형식이 생성되는 제네릭 형식 정의에 적용됩니다. 예를 들어 현재 TypeMyGenericType<int> (Visual Basic)를 나타내는 경우 MyGenericType(Of Integer) 이 속성의 값은 에 의해 MyGenericType<T> 결정됩니다.

현재 가 Type 제네릭 형식 또는 제네릭 메서드 정의에서 형식 매개 변수를 나타내는 경우 이 속성은 항상 false 를 반환합니다.

이 속성은 읽기 전용입니다.

적용 대상

추가 정보