The Microsoft .NET Common Language Runtime provides a shared type system, i
ntermediate language and dynamic execution environment for the implementati
on and inter-operation of multiple source languages. In this paper we exten
d it with direct support for parametric polymorphism (also known as generic
s), describing the design through examples written in an extended version o
f the C# programming language, and explaining aspects of implementation by
reference to a prototype extension to the runtime.
Our design is very expressive, supporting parameterized types, polymorphic
static, instance and virtual methods, "F-bounded" type parameters, instanti
ation at pointer and value types, polymorphic recursion, and exact run-time
types. The implementation takes advantage of the dynamic nature of the run
time, performing justin-time type specialization, representation-based code
sharing and novel techniques for efficient creation and use of Nn-time typ
es.
Early performance results are encouraging and suggest that programmers will
not need to pay an overhead for using generics, achieving performance almo
st matching hand-specialized code.