System.Reflection.Emit.DynamicILInfo.GetTokenFor Method

Gets a token, valid in the scope of the current System.Reflection.Emit.DynamicILInfo, representing a field to be accessed from the associated dynamic method.

Syntax

public int GetTokenFor (RuntimeFieldHandle field)

Parameters

field
The field to be accessed.

Returns

A token that can be used as the operand of an MSIL instruction that accesses fields, in the scope of the current System.Reflection.Emit.DynamicILInfo object.

Remarks

You must obtain a token for any field that will be accessed by the dynamic method associated with the current System.Reflection.Emit.DynamicILInfo object. Use the Type.GetField(string) method to get a System.Reflection.FieldInfo for the field you want to access, then use the System.Reflection.FieldInfo.FieldHandle property to get the RuntimeFieldHandle.

Requirements

Namespace: System.Reflection.Emit
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0