_FieldInfo.FieldHandleとは? わかりやすく解説

FieldInfo.FieldHandle プロパティ

フィールド内部メタデータ形式識別するハンドルである RuntimeFieldHandle取得します

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

Public MustOverride ReadOnly
 Property FieldHandle As RuntimeFieldHandle
Dim instance As FieldInfo
Dim value As RuntimeFieldHandle

value = instance.FieldHandle
public abstract RuntimeFieldHandle FieldHandle { get;
 }
public:
virtual property RuntimeFieldHandle FieldHandle {
    RuntimeFieldHandle get () abstract;
}
/** @property */
public abstract RuntimeFieldHandle get_FieldHandle ()
public abstract function get
 FieldHandle () : RuntimeFieldHandle

プロパティ
フィールド内部メタデータ形式識別するハンドル

解説解説
使用例使用例

MyClass.MyField のフィールド情報取得しフィールド ハンドル関連付けられているフィールド表示する例を次に示します

Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

Public Class [MyClass]
    Public MyField As String
 = "Microsoft"
End Class '[MyClass]

Public Class FieldInfo_FieldHandle
    Public Shared Sub Main()
        Dim [myClass] As New
 [MyClass]()
        ' Get the type of MyClass.
        Dim myType As Type = GetType([MyClass])
        Try
            ' Get the field information of MyField.
            Dim myFieldInfo As FieldInfo =
 myType.GetField("MyField", BindingFlags.Public Or
 BindingFlags.Instance)

            ' Determine whether or not the FieldInfo object is null.
            If Not (myFieldInfo Is
 Nothing) Then
                ' Get the handle for the field.
                Dim myFieldHandle As RuntimeFieldHandle
 = myFieldInfo.FieldHandle

                DisplayFieldHandle(myFieldHandle)
            Else
                Console.WriteLine("The myFieldInfo object is null.")
            End If
        Catch e As Exception
            Console.WriteLine(" Exception: {0}", e.Message.ToString())
        End Try
    End Sub 'Main

    Public Shared Sub DisplayFieldHandle(ByVal
 myFieldHandle As RuntimeFieldHandle)
        ' Get the type from the handle.
        Dim myField As FieldInfo = FieldInfo.GetFieldFromHandle(myFieldHandle)
        ' Display the type.
        Console.WriteLine(ControlChars.Cr + "Displaying the field
 from the handle." + ControlChars.Cr)
        Console.WriteLine("The type is {0}.", myField.ToString())
    End Sub 'DisplayFieldHandle
End Class 'FieldInfo_FieldHandle
using System;
using System.Reflection;
  
public class MyClass
{
    public string MyField = "Microsoft";
}

public class FieldInfo_FieldHandle
{
    public static void Main()
    {
    
        MyClass myClass =new MyClass();

        // Get the type of MyClass.
        Type myType = typeof(MyClass);

        try
        {
            // Get the field information of MyField.
            FieldInfo myFieldInfo = myType.GetField("MyField", BindingFlags.Public
 
                | BindingFlags.Instance);
      
            // Determine whether or not the FieldInfo object is null.
            if(myFieldInfo!=null)
            {
                // Get the handle for the field.
                RuntimeFieldHandle myFieldHandle=myFieldInfo.FieldHandle;

                DisplayFieldHandle(myFieldHandle);
            }
            else
            {
                Console.WriteLine("The myFieldInfo object is null.");
            }
        }  
        catch(Exception e)
        {
            Console.WriteLine("Exception: {0}", e.Message);
        }
    }

    public static void DisplayFieldHandle(RuntimeFieldHandle
 myFieldHandle)
    {
        // Get the type from the handle.
        FieldInfo myField = FieldInfo.GetFieldFromHandle(myFieldHandle);      
      
        // Display the type.
        Console.WriteLine("\nDisplaying the field from the handle.\n");
        Console.WriteLine("The type is {0}.", myField.ToString());
    }
}
using namespace System;
using namespace System::Reflection;

public ref class MyClass
{
public:
   String^ MyField;
};

void DisplayFieldHandle( RuntimeFieldHandle myFieldHandle )
{
   // Get the type from the handle.
   FieldInfo^ myField = FieldInfo::GetFieldFromHandle( myFieldHandle );

   // Display the type.
   Console::WriteLine( "\nDisplaying the field from the handle.\n" );
   Console::WriteLine( "The type is {0}.", myField );
}

int main()
{
   MyClass^ myClass = gcnew MyClass;

   // Get the type of MyClass.
   Type^ myType = MyClass::typeid;
   try
   {
      // Get the field information of MyField.
      FieldInfo^ myFieldInfo = myType->GetField( "MyField", static_cast<BindingFlags>(BindingFlags::Public
 | BindingFlags::Instance) );

      // Determine whether or not the FieldInfo Object* is 0.
      if ( myFieldInfo != nullptr )
      {
         // Get the handle for the field.
         RuntimeFieldHandle myFieldHandle = myFieldInfo->FieldHandle;
         DisplayFieldHandle( myFieldHandle );
      }
      else
      {
         Console::WriteLine( "The myFieldInfo Object* is 0." );
      }
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception: {0}", e->Message );
   }
}
import System.*;
import System.Reflection.*;

public class MyClass
{
   public String myField = "Microsoft";
} //MyClass

public class FieldInfoFieldHandle
{
    public static void main(String[]
 args)
    {
        MyClass myClass = new MyClass();

        // Get the type of MyClass.
        Type myType = MyClass.class.ToType();

        try {
            // Get the field information of myField.
            FieldInfo myFieldInfo = myType.GetField("myField", 
                BindingFlags.Public | BindingFlags.Instance);

            // Determine whether or not the FieldInfo object is null.
            if (myFieldInfo != null) {
                // Get the handle for the field.
                RuntimeFieldHandle myFieldHandle = myFieldInfo.
                    get_FieldHandle();
                DisplayFieldHandle(myFieldHandle);
            }
            else {
                Console.WriteLine("The myFieldInfo object is null.");
            }
        }
        catch (System.Exception e) {
                Console.WriteLine("Exception: {0}", e.get_Message());
        }
    } //main

    public static void DisplayFieldHandle(RuntimeFieldHandle
 myFieldHandle)
    {
        // Get the type from the handle.
        FieldInfo myField = FieldInfo.GetFieldFromHandle(myFieldHandle);

        // Display the type.
        Console.WriteLine("\nDisplaying the field from the handle.\n");
        Console.WriteLine("The type is {0}.", myField.ToString());
    } //DisplayFieldHandle
} //FieldInfoFieldHandle
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_FieldInfo.FieldHandle プロパティ

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

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

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

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

ReadOnly Property FieldHandle As
 RuntimeFieldHandle
Dim instance As _FieldInfo
Dim value As RuntimeFieldHandle

value = instance.FieldHandle
RuntimeFieldHandle FieldHandle { get; }
property RuntimeFieldHandle FieldHandle {
    RuntimeFieldHandle get ();
}
/** @property */
RuntimeFieldHandle get_FieldHandle ()
function get FieldHandle () : RuntimeFieldHandle

プロパティ
フィールド内部メタデータ形式識別するハンドル

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
_FieldInfo インターフェイス
_FieldInfo メンバ
System.Runtime.InteropServices 名前空間



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

辞書ショートカット

すべての辞書の索引

「_FieldInfo.FieldHandle」の関連用語

_FieldInfo.FieldHandleのお隣キーワード
検索ランキング

   

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



_FieldInfo.FieldHandleのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS