このインスタンスがリフレクションするフィールドの値を保持している FieldInfo を取得します。
Public Shared Function GetFieldFromHandle( _
ByVal handle As RuntimeFieldHandle _) As FieldInfo
[C#]
public static FieldInfo GetFieldFromHandle(RuntimeFieldHandlehandle);
[C++]
public: static FieldInfo* GetFieldFromHandle(RuntimeFieldHandlehandle);
[JScript]
public static function GetFieldFromHandle(
handle : RuntimeFieldHandle) : FieldInfo;
パラメータ
- handle
フィールドの内部メタデータ形式を識別するハンドル。
戻り値
このインスタンスがリフレクションするフィールドの値を保持している FieldInfo 。
解説
ハンドルは取得されたアプリケーション ドメインでだけ有効です。
使用例
[Visual Basic, C#, C++] 現在のインスタンスがリフレクションするフィールドの値を格納した FieldInfo を表示する例を次に示します。
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
Public Class FieldInfo_GetFieldFromHandle
Public x As String
Public y As Char
Public a As Single
Public b As Integer
Public Shared Sub Main()
' Get the type of the FieldInfo_GetFieldFromHandle class.
Dim myType As Type = GetType(FieldInfo_GetFieldFromHandle)
' Get the fields of the FieldInfo_GetFieldFromHandle class.
Dim myFieldInfoArray As FieldInfo() = myType.GetFields()
Console.WriteLine(ControlChars.NewLine & _
"The field information of the declared" & _
" fields x, y, a, and b is:" & ControlChars.NewLine)
Dim myRuntimeFieldHandle As RuntimeFieldHandle
Dim i As Integer
For i = 0 To myFieldInfoArray.Length - 1
' Get the RuntimeFieldHandle of myFieldInfoArray.
myRuntimeFieldHandle = myFieldInfoArray(i).FieldHandle
' Call the GetFieldFromHandle method.
Dim myFieldInfo As FieldInfo = FieldInfo.GetFieldFromHandle(myRuntimeFieldHandle)
' Display the FieldInfo of myFieldInfo.
Console.WriteLine("{0}", myFieldInfo)
Next i
End Sub 'Main
End Class 'FieldInfo_GetFieldFromHandle
[C#]
using System;
using System.Reflection;
public class FieldInfo_GetFieldFromHandle
{
public string x;
public char y;
public float a;
public int b;
public static void Main()
{
// Get the type of the FieldInfo_GetFieldFromHandle class.
Type myType = typeof(FieldInfo_GetFieldFromHandle);
// Get the fields of the FieldInfo_GetFieldFromHandle class.
FieldInfo [] myFieldInfoArray = myType.GetFields();
Console.WriteLine("\nThe field information of the declared" +
" fields x, y, a, and b is:\n");
RuntimeFieldHandle myRuntimeFieldHandle;
for(int i = 0; i < myFieldInfoArray.Length; i++)
{
// Get the RuntimeFieldHandle of myFieldInfoArray.
myRuntimeFieldHandle = myFieldInfoArray[i].FieldHandle;
// Call the GetFieldFromHandle method.
FieldInfo myFieldInfo = FieldInfo.GetFieldFromHandle(myRuntimeFieldHandle);
// Display the FieldInfo of myFieldInfo.
Console.WriteLine("{0}", myFieldInfo);
}
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;
public __gc class FieldInfo_GetFieldFromHandle
{
public:
String* x;
Char y;
float a;
int b;
};
int main()
{
// Get the type of the FieldInfo_GetFieldFromHandle class.
Type* myType = __typeof(FieldInfo_GetFieldFromHandle);
// Get the fields of the FieldInfo_GetFieldFromHandle class.
FieldInfo* myFieldInfoArray[] = myType->GetFields();
Console::WriteLine(S"\nThe field information of the declared fields x, y, a, and b is:\n");
RuntimeFieldHandle myRuntimeFieldHandle;
for (int i = 0; i < myFieldInfoArray->Length; i++) {
// Get the RuntimeFieldHandle of myFieldInfoArray.
myRuntimeFieldHandle = myFieldInfoArray[i]->FieldHandle;
// Call the GetFieldFromHandle method.
FieldInfo* myFieldInfo = FieldInfo::GetFieldFromHandle(myRuntimeFieldHandle);
// Display the FieldInfo of myFieldInfo.
Console::WriteLine(S" {0}", myFieldInfo);
}
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
.NET Framework セキュリティ:
- ReflectionPermission (Type.InvokeMember などの機構を通じて遅延バインディングで呼び出すときに必要なアクセス許可) ReflectionPermissionFlag.MemberAccess (関連する列挙体)