I would like to have a collection (e.g. List or Dictionary, or even an array) of Generic objects. For example, imagine I've defined a generic class 'Pair' that takes any two things. In order to create a List of Pair objects, I'd have to define it like this:
dim objList as List(Of Pair(Of String, Integer))
Unfortunately, this means that every item in the list can only be an instance of Pair(String, Integer), and thus I'm not able to take full advantage of the generics paradigm as I understand it.
I know I could create a more general superclass from which Pair inherits, but I don't want the list to contain just any object that inherits from the superclass; I want it to contain Pair objects and Pair objects alone.
Is there any way that this can be done?