Generic Constraint
Generic Constraint
When constraints are applied using the where keyword, the constraint
list is placed after the
generic type’s base class and interface list. By way of a few concrete
examples, consider the following
constraints of a generic class named MyGenericClass:
{...}
// MyGenericClass derives from Object, while
// contained items must be a class implementing
IDrawable
// and support a default ctor.
IDrawable, new()
{...}
{...}
where T : IComparable<T>
{...}