FieldInfo.GetFieldFromHandle Method (RuntimeFieldHandle)
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets a FieldInfo for the field represented by the specified handle.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Shared Function GetFieldFromHandle ( _ handle As RuntimeFieldHandle _ ) As FieldInfo
Parameters
- handle
- Type: System.RuntimeFieldHandle
A structure that contains the handle to the internal metadata representation of a field.
| Exception | Condition |
|---|---|
| ArgumentException | handle is invalid. |
| MethodAccessException | The member is invoked late-bound through mechanisms such as Type.InvokeMember. |
The following 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.
Note: |
|---|
To run this example, see Building examples that have static TextBlock controls for Windows Phone 8. |
Imports System.Reflection Public Class Example Public x As String Public y As Char Public a As Single Public b As Integer Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) ' Get the type of the Example class. Dim myType As Type = GetType(Example) ' Get the fields of the Example class. Dim myFieldInfoArray As FieldInfo() = myType.GetFields() outputBlock.Text &= ControlChars.NewLine & _ "The field information of the declared" & _ " fields x, y, a, and b is:" & ControlChars.NewLine & vbCrLf 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. outputBlock.Text &= String.Format("{0}", myFieldInfo) & vbCrLf Next i End Sub 'Main End Class 'FieldInfo_GetFieldFromHandle
Note: