Generic Types
A generic type is a single programming element that adapts to perform the same functionality for a variety of data types. When you define a generic class or procedure, you do not have to define a separate version for each data type for which you might want to perform that functionality.
An analogy is a screwdriver set with removable heads. You inspect the screw you need to turn and select the correct head for that screw (slotted, crossed, starred). Once you insert the correct head in the screwdriver handle, you perform the exact same function with the screwdriver, namely turning the screw.
Screwdriver set as a generic tool
When you define a generic type, you parameterize it with one or more data types. This allows the using code to tailor the data types to its requirements. Your code can declare several different programming elements from the generic element, each one acting on a different set of data types. But the declared elements all perform the identical logic, no matter what data types they are using.
For example, you might want to create and use a queue class that operates on a specific data type such as String. You can declare such a class from System.Collections.Generic.Queue<T>, as the following example shows.
Public stringQ As New System.Collections.Generic.Queue(Of String)
You can now use stringQ to work exclusively with String values. Because stringQ is specific for String instead of being generalized for Object values, you do not have late binding or type conversion. This saves execution time and reduces run-time errors.
A class that takes type parameters is called a generic class. If you are using a generic class, you can generate a constructed class from it by supplying a type argument for each of these parameters. You can then declare a variable of the constructed class type, and you can create an instance of the constructed class and assign it to that variable.
