Lecture overview -- Keyboard shortcut: 'u'  Previous page: Generic Types -- Keyboard shortcut: 'p'  Next page: Constraints: Strings of comparable elements -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Alphabetic index  Help page about these notes  Course home    Generic Types and Methods - slide 9 : 21

Constraints on Formal Type Parameters

It is possible to express a number of constraints on a formal type parameter

The more constraints on T, the more we can do on T-objects in the body of C<T>

class C<S,T>: D  
    where T: A, ICloneable
    where S: B {
 ...
}

class E<T>: D
    where T: class{
 ...
}

class F<T>: D
    where T: struct{
 ...
}

class G<T>: D
    where T: new(){
 ...
}