Type.GetTypeFromHandle(RuntimeTypeHandle) 方法

定义

获取由指定类型句柄引用的类型。

C#
public static Type GetTypeFromHandle (RuntimeTypeHandle handle);

参数

handle
RuntimeTypeHandle

引用类型的对象。

返回

Type

如果 RuntimeTypeHandlenull 属性为 Value,则为由指定的 handle 引用的类型,或者为 null

例外

调用了类初始值设定项,且该项引发了异常。

示例

下面的示例使用 GetTypeFromHandle 方法 Type 从方法提供的中获取一个对象 RuntimeTypeHandle GetTypeHandle

C#
MyClass1 myClass1 = new MyClass1();
 // Get the type referenced by the specified type handle.
Type myClass1Type = Type.GetTypeFromHandle(Type.GetTypeHandle(myClass1));
Console.WriteLine("The Names of the Attributes :"+myClass1Type.Attributes);

注解

句柄仅在获取它们的应用程序域中有效。

适用于

产品 版本
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1
UWP 10.0

另请参阅