10.8. Nested Generic TypesThe type parameters included in a class definition can be used within nested classes: Public Class Level1(Of T1, T2) Public Class Level2 Public theData As T1 End Class End Class However, when you create instances of the outer and inner classes based on different specified parameters, the resulting instances are fully unrelated. For instance, using the Level1 and Level2 classes just defined, the statements: Dim first As New Level1(Integer, Double).Level2 Dim second As Level1(Integer, String).Level2 first.theData = 5 second = first ' This line will not compile will not compile successfully. Even though the Level2 classes both contain only an Integer public member, they are not compatible because each class is tied to a different set of data types. Nested types may also include their own type parameters. Public Class Level1(Of T1, T2) Public Class Level2(Of T3) Public theData As T3 End Class End Class |