DynamicILInfo.GetTokenFor Method (RuntimeMethodHandle, RuntimeTypeHandle)


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

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

public int GetTokenFor(
	RuntimeMethodHandle method,
	RuntimeTypeHandle contextType


Type: System.RuntimeMethodHandle

The method.

Type: System.RuntimeTypeHandle

The generic type the method belongs to.

Return Value

Type: System.Int32

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

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

.NET Framework
Available since 2.0
Return to top