Type.IsEnum 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 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
속성 값
true 현재 Type 열거형을 나타내는 경우, 그렇지 않으면 false.
구현
예제
다음 예제에서는 속성을 사용 하는 방법을 보여 줍니다 IsEnum .
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.
open System
type Color =
| Red = 0
| Blue = 1
| Green = 2
let colorType = typeof<Color>
let enumType = typeof<Enum>
printfn $"Is Color an enum? {colorType.IsEnum}."
printfn $"Is Color a value type? {colorType.IsValueType}."
printfn $"Is Enum an enum Type? {enumType.IsEnum}."
printfn $"Is Enum a value type? {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 생성 된 제네릭 형식을 나타내는 경우이 속성은 형식이 생성 된 제네릭 형식 정의에 적용 됩니다. 예를 들어 현재 Type 가 (Visual Basic에서)MyGenericType<int> 나타내는 MyGenericType(Of Integer) 경우 이 속성의 값은 .에 의해 MyGenericType<T>결정됩니다.
현재 Type 제네릭 형식 또는 제네릭 메서드의 정의에서 형식 매개 변수를 나타내는 경우 이 속성은 항상 반환됩니다 false.
이 속성은 읽기 전용입니다.