Type.GetTypeFromHandle 方法
获取由指定类型句柄引用的类型。
**命名空间:**System
**程序集:**mscorlib(在 mscorlib.dll 中)
语法
声明
Public Shared Function GetTypeFromHandle ( _
handle As RuntimeTypeHandle _
) As Type
用法
Dim handle As RuntimeTypeHandle
Dim returnValue As Type
returnValue = Type.GetTypeFromHandle(handle)
public static Type GetTypeFromHandle (
RuntimeTypeHandle handle
)
public:
static Type^ GetTypeFromHandle (
RuntimeTypeHandle handle
)
public static Type GetTypeFromHandle (
RuntimeTypeHandle handle
)
public static function GetTypeFromHandle (
handle : RuntimeTypeHandle
) : Type
参数
- handle
引用类型的 RuntimeTypeHandle 对象。
返回值
指定 RuntimeTypeHandle 引用的类型。
异常
异常类型 | 条件 |
---|---|
handle 为 空引用(在 Visual Basic 中为 Nothing)。 |
|
调用类初始值设定项并引发异常。 |
备注
这些句柄仅在获取它们的应用程序域中有效。
如果请求的类型是非公共类型,并且调用方不具有 ReflectionPermission 来反射当前程序集之外的非公共对象,则此方法返回 空引用(在 Visual Basic 中为 Nothing)。
示例
Dim myClass1 As New MyClass1()
' Get the type referenced by the specified type handle.
Dim myClass1Type As Type = Type.GetTypeFromHandle(Type.GetTypeHandle(MyClass1))
Console.WriteLine(("The Names of the Attributes :" + myClass1Type.Attributes.ToString()))
End Sub 'Main
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);
MyClass1^ myClass1 = gcnew MyClass1;
// Get the type referenced by the specified type handle.
Type^ myClass1Type = Type::GetTypeFromHandle( Type::GetTypeHandle( myClass1 ) );
Console::WriteLine( "The Names of the Attributes : {0}", myClass1Type->Attributes );
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.
get_Attributes());
.NET Framework 安全性
- ReflectionPermission 用于反射非公共对象。关联的枚举:ReflectionPermissionFlag.TypeInformation
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
.NET Compact Framework
受以下版本支持:2.0、1.0
请参见
参考
Type 类
Type 成员
System 命名空间
RuntimeTypeHandle 结构
TypeHandle
GetTypeHandle
ReflectionPermission