Defines and creates generic type parameters for dynamically defined generic types and methods. This class cannot be inherited.
See Also: GenericTypeParameterBuilder Members
You can get an array of System.Reflection.Emit.GenericTypeParameterBuilder objects by using the TypeBuilder.DefineGenericParameters(String[]) method to add type parameters to a dynamic type, thus making it a generic type, or by using the MethodBuilder.DefineGenericParameters(String[]) method to add type parameters to a dynamic method. Use the System.Reflection.Emit.GenericTypeParameterBuilder objects to add constraints to the type parameters. Constraints are of three kinds:
The base type constraint specifies that any type assigned to the generic type parameter must derive from a particular base type. Set this constraint by using the GenericTypeParameterBuilder.SetBaseTypeConstraint(Type) method.
An interface constraint specifies that any type assigned to the generic type parameter must implement a particular interface. Set the interface constraints by using the GenericTypeParameterBuilder.SetInterfaceConstraints(Type[]) method.
Special constraints specify that any type assigned to the generic type parameter must have a default constructor, must be a reference type, or must be a value type. Set the special constraints for a type parameter by using the GenericTypeParameterBuilder.SetGenericParameterAttributes(System.Reflection.GenericParameterAttributes) method.
Interface constraints and special constraints cannot be retrieved using methods of the System.Reflection.Emit.GenericTypeParameterBuilder class. Once you have created the generic type that contains the type parameters, you can use its Type object to reflect the constraints. Use the Type.GetGenericArguments method to get the type parameters, and for each type parameter use the Type.GetGenericParameterConstraints method to get the base type constraint and interface constraints, and the Type.GenericParameterAttributes property to get the special constraints.