_Type.TypeHandle プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > _Type.TypeHandle プロパティの意味・解説 

_Type.TypeHandle プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

COM オブジェクトに、Type.TypeHandle プロパティへのバージョン依存しないアクセス用意されています。

このプロパティは、CLS準拠していません。  

名前空間: System.Runtime.InteropServices
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

ReadOnly Property TypeHandle As
 RuntimeTypeHandle
Dim instance As _Type
Dim value As RuntimeTypeHandle

value = instance.TypeHandle
RuntimeTypeHandle TypeHandle { get; }
property RuntimeTypeHandle TypeHandle {
    RuntimeTypeHandle get ();
}
/** @property */
RuntimeTypeHandle get_TypeHandle ()
function get TypeHandle () : RuntimeTypeHandle

プロパティ
現在の Typeハンドル

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Type.TypeHandle プロパティ

現在の Typeハンドル取得します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Overridable ReadOnly
 Property TypeHandle As RuntimeTypeHandle
Dim instance As Type
Dim value As RuntimeTypeHandle

value = instance.TypeHandle
public virtual RuntimeTypeHandle TypeHandle { get;
 }
public:
virtual property RuntimeTypeHandle TypeHandle {
    RuntimeTypeHandle get ();
}
/** @property */
public RuntimeTypeHandle get_TypeHandle ()
public function get TypeHandle
 () : RuntimeTypeHandle

プロパティ
現在の Typeハンドル

例外例外
例外種類条件

NotSupportedException

.NET Compact Framework は、現在このプロパティサポートしていません。

解説解説
使用例使用例

対応する型のハンドル取得し、そのハンドルハンドルから型を取得して表示を行うメソッドに渡す例を次に示します

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
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Type クラス
Type メンバ
System 名前空間
RuntimeTypeHandle 構造体
GetTypeHandle
GetTypeFromHandle


このページでは「.NET Framework クラス ライブラリ リファレンス」から_Type.TypeHandle プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書から_Type.TypeHandle プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書から_Type.TypeHandle プロパティを検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「_Type.TypeHandle プロパティ」の関連用語

_Type.TypeHandle プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



_Type.TypeHandle プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS