If there were a minimum federal government data type placeholder requirement, the implementation of generics just described would certainly meet it. It's kind of nice to postpone the definition of data types until the last minute. But .NET generics don't stop there.
Generic placeholders—also known as type parameters—are like those knives you buy on late-night TV. You don't get one; you get more! As many as you need, it turns out. Each generic class can include multiple placeholders by adding them to the initial
Class MultiTypes(Of T1, T2) Public Member1 As T1 Public Member2 As T2 End Class
As before, you aren't required to use the boring names T1 and T2. Whatever names you choose, include them as a comma-separated list just after the
Of keyword. When you're ready to create an instance, replicate the comma-delimited list in the same order, but using actual types. In this statement,
Dim useInstance As MultiTypes(Of Integer, String)
The type parameters you include in a generic, such as
T, accept any valid data type, including
System.Windows.Forms.Form, or your own custom types. That is,
T can be replaced by anything that derives from
System.Object, which is everything. You can even imagine the statement:
Class SomeClass(Of T)
being replaced by:
Class SomeClass(Of T
As clause to make it look like other ...