Re: Derive concrete type from generic type.
Frans Bouma <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.clr |
|---|---|
| Message-ID | <00fc01c85cf4$07036de0$150a49a0$@nl> |
> Frans is essentially right BUT... =)
>
> Some of us argue that inheriting classes such as List<T> to create new types
> is a bad thing.
> This discussion is more common in the JAVA community. Prior to completing
your
> impl. I recomend that you read this java article about inheritence VS
> interface implementation.
>
> http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html
>
> Regards,
> Daniel
>
> ps the article is old and doesn't use generics but the problem I still the
> same ds
I agree, to some extend. The thing with non-generic classes which are
collections is that you might run into co-/contra-variance problems. (i.e.
MyFieldList isn't castable to List<object>)
The downside of using generics is that you need to know the generic
argument if you want to use the object, otherwise you've to fall back onto a
non-generic interface. So if you have a non-generic interface (in this case,
you have IList, but it doesn't cover MyFieldList specific elements) on the
type as well, you can use that to use the object, otherwise you'll run the
risk of not being able to use an of type MyFieldList<T> because you don't know
the type of T
FB
===================================
This list is hosted by DevelopMentor® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com