C# FieldInfo GetFieldFromHandle (RuntimeFieldHandle)
Description
FieldInfo GetFieldFromHandle(RuntimeFieldHandle)
Gets
a FieldInfo for the field represented by the specified handle.
Syntax
FieldInfo.GetFieldFromHandle(RuntimeFieldHandle)
has the following syntax.
public static FieldInfo GetFieldFromHandle(
RuntimeFieldHandle handle
)
Parameters
FieldInfo.GetFieldFromHandle(RuntimeFieldHandle)
has the following parameters.
handle
- A RuntimeFieldHandle structure that contains the handle to the internal metadata representation of a field.
Returns
FieldInfo.GetFieldFromHandle(RuntimeFieldHandle)
method returns A FieldInfo object representing the field specified by handle.
Example
using System;// w w w . j ava 2s .c o m
using System.Reflection;
public class FieldInfo_GetFieldFromHandle
{
public string x;
public char y;
public float a;
public int b;
public static void Main()
{
Type myType = typeof(FieldInfo_GetFieldFromHandle);
FieldInfo [] myFieldInfoArray = myType.GetFields();
RuntimeFieldHandle myRuntimeFieldHandle;
for(int i = 0; i < myFieldInfoArray.Length; i++)
{
myRuntimeFieldHandle = myFieldInfoArray[i].FieldHandle;
FieldInfo myFieldInfo = FieldInfo.GetFieldFromHandle(myRuntimeFieldHandle);
Console.WriteLine(myFieldInfo);
}
}
}
The code above generates the following result.