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; the field is on the specified generic type.

Syntax

public int GetTokenFor (RuntimeFieldHandle field, RuntimeTypeHandle contextType)

Parameters

field
The field to be accessed.
contextType
The generic type the field belongs to.

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, and then use the System.Reflection.FieldInfo.FieldHandle property to get the RuntimeFieldHandle.

Requirements

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