TypeBuilder.GetMethod Method (Type, MethodInfo)
Returns the method of the specified constructed generic type that corresponds to the specified method of the generic type definition.
Assembly: mscorlib (in mscorlib.dll)
- Type: System.Type
The constructed generic type whose method is returned.
- Type: System.Reflection.MethodInfo
A method on the generic type definition of type, which specifies which method of type to return.
Return ValueType: System.Reflection.MethodInfo
The method of type corresponding to method, which specifies a method belonging to the generic type definition of type.
method is a generic method that is not a generic method definition.
type does not represent a generic type.
type is not of type TypeBuilder.
The declaring type of method is not a generic type definition.
The declaring type of method is not the generic type definition of type.
For example, suppose you have a TypeBuilder object that represents the type G<T> in C# syntax (G(Of T) in Visual Basic, generic <T> ref class G in C++) and a MethodBuilder object that represents a method T M() in C# syntax (Function M() As T in Visual Basic, T M() in C++) that is defined by G<T>. Suppose that G<T> has a generic method with type parameter U that creates an instance of the constructed type G<U> and calls method M on that instance. In order to emit the function call, you need a MethodInfo object that represents M on the constructed type — in other words, that returns type U rather than type T. To do this, first call the MakeGenericType method on the TypeBuilder object, specifying the GenericTypeParameterBuilder object that represents U as the type argument. Then call the GetMethod method with the return value of the MakeGenericType method as parameter type and the MethodBuilder object that represents T M() as parameter method. The return value is the MethodInfo object you need to emit the function call. The code example for the GetField method demonstrates a scenario similar to this.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.