System.Reflection.Emit.DynamicILInfo.GetTokenFor Method

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

Syntax

public int GetTokenFor (RuntimeMethodHandle method)

Parameters

method
The method to be accessed.

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 accessed by the dynamic method associated with the current System.Reflection.Emit.DynamicILInfo object. Use the erload:System.Type.GetMethod method to get a System.Reflection.MethodInfo for the method you want to access, and then use the System.Reflection.MethodBase.MethodHandle property to get the RuntimeMethodHandle.

Note:

For a method that belongs to a generic type, use the DynamicILInfo.GetTokenFor(RuntimeMethodHandle, RuntimeTypeHandle) method overload and specify a RuntimeTypeHandle for the generic type.

Requirements

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