Sets the number of generic type parameters for the current method, specifies their names, and returns an array of GenericTypeParameterBuilder objects that can be used to define their constraints.
Assembly: mscorlib (in mscorlib.dll)
- Type: System.String
An array of strings that represent the names of the generic type parameters.
Return ValueType: System.Reflection.Emit.GenericTypeParameterBuilder
An array of GenericTypeParameterBuilder objects representing the type parameters of the generic method.
Generic type parameters have already been defined for this method.
The method has been completed already.
The SetImplementationFlags method has been called for the current method.
names is a null reference (Nothing in Visual Basic).
An element of names is a null reference (Nothing in Visual Basic).
names is an empty array.
Calling the method makes the current method generic. There is no way to undo this change. Calling this method a second time causes an InvalidOperationException.
The type parameters of the generic method can be retrieved later by using the GetGenericArguments method.
By convention, a type parameter name is a single uppercase letter.
The following code example creates a dynamic type, DemoType, which contains the dynamic generic method DemoMethod. This method has two generic type parameters, one of which is used as a parameter, and the other as the return type.
When the code is executed, the dynamic assembly is saved as DemoGenericMethod1.dll, and can be examined using the Ildasm.exe (MSIL Disassembler).
This code example generates a simple method body that merely returns a null reference. For a code example with a more fully developed method body that creates and uses generic types, see How to: Define a Generic Method with Reflection Emit.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.