System.Reflection.Emit.DynamicILInfo.GetTokenFor Method

Gets a token, valid in the scope of the current System.Reflection.Emit.DynamicILInfo, representing a method on a generic type.

Syntax

public int GetTokenFor (RuntimeMethodHandle method, RuntimeTypeHandle contextType)

Parameters

method
The method.
contextType
The generic type the method belongs to.

Returns

A token that can be used as the operand of an MSIL instruction that accesses methods, such as OpCodes.Call or OpCodes.Ldtoken, in the scope of the current System.Reflection.Emit.DynamicILInfo object.

Remarks

You must obtain a token for any method that will be called by the dynamic method associated with the current System.Reflection.Emit.DynamicILInfo object. Use the Type.GetMethod(string) method to get a System.Reflection.MethodInfo for the method you want to call, and then use the System.Reflection.MethodBase.MethodHandle property to get the RuntimeMethodHandle.

Requirements

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