GetFieldFromHandle Method (RuntimeFieldHandle)
Collapse the table of content
Expand the table of content

FieldInfo::GetFieldFromHandle Method (RuntimeFieldHandle)


Gets a FieldInfo for the field represented by the specified handle.

Namespace:   System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

static FieldInfo^ GetFieldFromHandle(
	RuntimeFieldHandle handle


Type: System::RuntimeFieldHandle

A RuntimeFieldHandle structure that contains the handle to the internal metadata representation of a field.

Return Value

Type: System.Reflection::FieldInfo^

A FieldInfo object representing the field specified by handle.

Exception Condition

handle is invalid.

Handles are valid only in the application domain in which they were obtained.

The following code example uses the Type::GetFields method to get FieldInfo objects for the fields of a type, gets a RuntimeFieldHandle structure for each field, and then retrieves the FieldInfo objects from the handles using this overload of the GetFieldFromHandle method.

using namespace System;
using namespace System::Reflection;

public ref class FieldInfo_GetFieldFromHandle
   String^ x;
   Char y;
   float a;
   int b;

int main()
   // Get the type of the FieldInfo_GetFieldFromHandle class.
   Type^ myType = FieldInfo_GetFieldFromHandle::typeid;

   // Get the fields of the FieldInfo_GetFieldFromHandle class.
   array<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 );


when invoked late-bound through mechanisms such as Type::InvokeMember. Associated enumeration: ReflectionPermissionFlag::MemberAccess.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2016 Microsoft