Sets the variance characteristics and special constraints of the generic parameter, such as the parameterless constructor constraint.
Assembly: mscorlib (in mscorlib.dll)
member SetGenericParameterAttributes : genericParameterAttributes:GenericParameterAttributes -> unit
Special constraints can 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.
Special constraints cannot be retrieved using methods of the GenericTypeParameterBuilder class. Once you have created the generic type that contains the type parameter, you can use its Type object to reflect the type parameters and their constraints. To get the type parameters of a completed generic type, use the Type.GetGenericArguments method. To get the special constraints for each type parameter, use the Type.GenericParameterAttributes property.
The GenericParameterAttributes enumeration values that refer to the variance characteristics of a type parameter are relevant only in languages that support covariance and contravariance, such as Microsoft intermediate language (MSIL). Visual Basic and C# currently do not support covariance and contravariance.
The following code example creates a generic type with two type parameters, the first of which is constrained to have a default constructor and to be a reference type, and saves them in the assembly GenericEmitExample1.dll. You can use the Ildasm.exe (MSIL Disassembler) to view the generated types. For a more detailed explanation of the steps involved in defining a dynamic generic type, see How to: Define a Generic Type 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.