Type.TypeHandle プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)




対応する型のハンドルを取得し、そのハンドルをハンドルから型を取得して表示を行うメソッドに渡す例を次に示します。
Imports System Imports System.Reflection Imports Microsoft.VisualBasic Class [MyClass] Public myField As Integer = 10 End Class '[MyClass] Class Type_TypeHandle Public Shared Sub Main() Try Dim [myClass] As New [MyClass]() ' Get the type of MyClass. Dim myClassType As Type = [myClass].GetType() ' Get the runtime handle of MyClass. Dim myClassHandle As RuntimeTypeHandle = myClassType.TypeHandle DisplayTypeHandle(myClassHandle) Catch e As Exception Console.WriteLine("Exception: {0}", e.Message.ToString()) End Try End Sub 'Main Public Shared Sub DisplayTypeHandle(ByVal myTypeHandle As RuntimeTypeHandle) ' Get the type from the handle. Dim myType As Type = Type.GetTypeFromHandle(myTypeHandle) ' Display the type. Console.WriteLine(ControlChars.NewLine + "Displaying the type from the handle:" + ControlChars.NewLine) Console.WriteLine("The type is {0}.", myType.ToString()) End Sub 'DisplayTypeHandle End Class 'Type_TypeHandle
using System; using System.Reflection; class MyClass { public int myField = 10; } class Type_TypeHandle { public static void Main() { try { MyClass myClass = new MyClass(); // Get the type of MyClass. Type myClassType = myClass.GetType(); // Get the runtime handle of MyClass. RuntimeTypeHandle myClassHandle = myClassType.TypeHandle; DisplayTypeHandle(myClassHandle); } catch(Exception e) { Console.WriteLine("Exception: {0}", e.Message ); } } public static void DisplayTypeHandle(RuntimeTypeHandle myTypeHandle) { // Get the type from the handle. Type myType = Type.GetTypeFromHandle(myTypeHandle); // Display the type. Console.WriteLine("\nDisplaying the type from the handle:\n"); Console.WriteLine("The type is {0}.", myType.ToString()); } }
using namespace System; using namespace System::Reflection; ref class MyClass { public: int myField; }; void DisplayTypeHandle( RuntimeTypeHandle myTypeHandle ) { // Get the type from the handle. Type^ myType = Type::GetTypeFromHandle( myTypeHandle ); // Display the type. Console::WriteLine( "\nDisplaying the type from the handle:\n" ); Console::WriteLine( "The type is {0}.", myType ); } int main() { try { MyClass^ myClass = gcnew MyClass; // Get the type of MyClass. Type^ myClassType = myClass->GetType(); // Get the runtime handle of MyClass. RuntimeTypeHandle myClassHandle = myClassType->TypeHandle; DisplayTypeHandle( myClassHandle ); } catch ( Exception^ e ) { Console::WriteLine( "Exception: {0}", e->Message ); } }
import System.*; import System.Reflection.*; class MyClass { public int myField = 10; } //MyClass class Type_TypeHandle { public static void main(String[] args) { try { MyClass myClass = new MyClass(); // Get the type of MyClass. Type myClassType = myClass.GetType(); // Get the runtime handle of MyClass. RuntimeTypeHandle myClassHandle = myClassType.get_TypeHandle(); DisplayTypeHandle(myClassHandle); } catch (System.Exception e) { Console.WriteLine("Exception: {0}", e.get_Message()); } } //main public static void DisplayTypeHandle(RuntimeTypeHandle myTypeHandle) { // Get the type from the handle. Type myType = Type.GetTypeFromHandle(myTypeHandle); // Display the type. Console.WriteLine("\nDisplaying the type from the handle:\n"); Console.WriteLine("The type is {0}.", myType.ToString()); } //DisplayTypeHandle } //Type_TypeHandle

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_Type.TypeHandle プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)



Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からType.TypeHandleを検索する場合は、下記のリンクをクリックしてください。

- Type.TypeHandleのページへのリンク