Generics were one of the most prominent features added to .NET Framework 2.0. With generics you can write a parameterized type and create instances of it by passing a type or types. The objects will then be restricted to the type(s). In addition to parameterized types, generics support parameterized methods.
The benefit of generics include stricter type checking at compile time and performance improvement. In addition, generics eliminate most type castings you would otherwise have to perform when working with members of the System.Collections namespace.
This chapter explains how you can use and write generic types. It starts with the section “Why Generics?” and then presents some examples of generic types. After a discussion ...