지정된 유형 핸들이 참조하는 유형을 가져오려면 코드는 다음과 같습니다. -
예
using System;
public class Demo {
public static void Main() {
Type type1 = typeof(short);
RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);
Type type = Type.GetTypeFromHandle(typeHandle);
Console.WriteLine("Attributes = " + type.Attributes);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInit
예
다른 예를 살펴보겠습니다 -
using System;
public class Demo {
public static void Main() {
Type type1 = typeof(System.Type);
RuntimeTypeHandle typeHandle = Type.GetTypeHandle(type1);
Type type = Type.GetTypeFromHandle(typeHandle);
Console.WriteLine("Attributes = " + type.Attributes);
}
} 출력
이것은 다음과 같은 출력을 생성합니다 -
Attributes = AutoLayout, AnsiClass, Class, Serializable, BeforeFieldInit