#1,070 – A Generic Type Can Be Compiled

Recall that a generic type is a template for a class that you can define later.  The generic type contains type parameters that act as placeholders for type arguments that you supply when you define a constructed type based on the generic type.  Without defining the constructed type, the type parameters in the generic type have no assigned type.  That is, they can be of any type (unless some constraints have been specified for the type parameter).

You can compile a particular generic type without have any constructed types that make use of the generic type.  For example, List<T> is compiled and included in mscorlib.dll.  This allows you to later use the generic type in your own code.

Advertisement