uriye <ur***@discussions.microsoft.com> wrote:
Why isn't List<A> a subclass of List<B> if A is a subclass of B ?
This fact causes a lot of design problems. Making the generic collections
loose their type safty strength in large designs.
Maybe there is a design pattern to overcome this problem ? Or maybe someone
knows other related facts ?
Suppose you have List<FileStream> and try to use it as a List<Stream> -
you would be able to add a List<NetworkStream> to it, which wouldn't be
good. (This is how arrays work, with runtime exceptions, and I'm not at
all sure it's ideal.)
So in fact, currently we *do* have type safe collections - but with
your suggestion, they wouldn't be type safe any more.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too