Yes I can cast however a substantial part of the raison d'etre for generics
is that we remove casting n'est pas? And if I'm going to cast anyway why add
the complexity of generics, it could be implemented as a straight hierarchy
from Base with a Foo interface. That however fixes the implementation and I
lose any chance to reuse the code for other purposes.
I guess my point is that I can see no reason to preclude the syntax and it
does make the implementation cleaner, and it certainly makes for better code
reuse, so why disallow it? It appears the compiler is naively comparing
Foo(Of Base) and Foo(Of DerivedBase) and saying there is no relationship;
whereas there truly is an inheritance relationship just as there is an
inheritance relationship between Base and DerivedBase.
The utility is enhanced if we introduce another class Derived2Base which is
also derived from Base. I can then use a reference to Foo(Of Base) for either
one which is the generics equivalent of being able to use a fruit reference
to access apples or bananas.
"Mattias Sjögren" wrote:
Any (clean) workarounds?
I'm not sure what kind of workaround you're looking for. But you can
use just a Foo(Of Base) for both Base and DerivedBase instances. Of
course that means you have to cast whenever you need to use
DerivedBase specific functionality.
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.