CodeTypeParameter.Constraints Property


Gets the constraints for the type parameter.

Namespace:   System.CodeDom
Assembly:  System (in System.dll)

public CodeTypeReferenceCollection Constraints { get; }

Property Value

Type: System.CodeDom.CodeTypeReferenceCollection

A CodeTypeReferenceCollection object that contains the constraints for the type parameter.

A constraint specifies the type that the type parameter must derive from or implement.

The following code example shows the use of the Constraints property to add a new constraint. This example is part of a larger example provided for the CodeTypeParameter class.

kType.Constraints.Add(new CodeTypeReference(typeof(IComparable)));

.NET Framework
Available since 2.0
Return to top