Is something like this possible?
Dim l As New List(Of T As Type Where GetType(BaseClass).IsAssignableFrom(T))
Note, my collection will be a collection of Types, not objects of type T – which I know is possible.
ETA:
The answers I’ve had so far are as expected – I didn’t think it was possible.
What I’m trying to get my head round is why the following can resolved at compile time, but not my example:
Dim l as New List(Of T As BassClass)
Are the checks not, essentially, the same?
You can have a runtime enforced constraint on your collection like this:
Edit: You could also do the following and get full compile-time type safety as long as you call the generic
Add<T>(),Contains<T>(), andRemove<T>()methods.