Constraints on Type Parameters (C#)
Full Name:
Constraints on Type Parameters (C#)
Short Name:
Constraints on Type Parameters (C#)
Type of Entity:
C#
Abstract:
When you define a generic class, you can apply restrictions to the kinds of types that client code can use for type arguments when it instantiates your class. If client code attempts to instantiate your class with a type that is not allowed by a constraint, the result is a compile-time error. These restrictions are called constraints. Constraints are specified using the where contextual keyword. The following table lists the six types of constraints:
MSDN Source URL:
http://msdn2.microsoft.com/d5x73970.aspx