System.Reflection.Emit.MethodBuilder.DefineGenericParameters Method

Sets the number of generic type parameters for the current method, specifies their names, and returns an array of System.Reflection.Emit.GenericTypeParameterBuilder objects that can be used to define their constraints.

Syntax

public GenericTypeParameterBuilder[] DefineGenericParameters (params string[] names)

Parameters

names
An array of strings that represent the names of the generic type parameters.

Returns

An array of System.Reflection.Emit.GenericTypeParameterBuilder objects representing the type parameters of the generic method.

Remarks

Calling the MethodBuilder.DefineGenericParameters(String[]) 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 MethodBuilder.GetGenericArguments method.

By convention, a type parameter name is a single uppercase letter.

For more information, see System.Reflection.MethodInfo.IsGenericMethod and System.Reflection.MethodInfo.GetGenericMethodDefinition. For information on generic types, see Type.IsGenericType.

Requirements

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