M
Morgan Cheng
In .Net 2.0, Generics are introduced. I found that IEnumerable<T>
inherites from IEnumerable. This makes implementation of
IEnumerable<T> has to have two GetEnumerator methods defined( one for
IEnumerable<T> and the other for IEnumerable). I doubt why .Net class
hierarchy is designed in such a way. IMHO, they should not have
inheritance releationship, just like IList<T> and IList.
I googled the web and found two related articles.
http://www.wintellect.com/cs/blogs/...2/13/ienumerable-lt-t-gt-and-ienumerable.aspx
http://blogs.msdn.com/brada/archive/2005/01/18/355755.aspx
But, the explanation is not satisfying.
Even though "IEnumerable<T> inherits from IEnumerable" seems follow
Liskov Substitution Principle, I believe, LSP is just a necessary
condition, not sufficent condition. And, If IEnumerable<T> doesn't
inherit from IEnumerable, no old code would be broken.
Anybody can shed some light on that?
inherites from IEnumerable. This makes implementation of
IEnumerable<T> has to have two GetEnumerator methods defined( one for
IEnumerable<T> and the other for IEnumerable). I doubt why .Net class
hierarchy is designed in such a way. IMHO, they should not have
inheritance releationship, just like IList<T> and IList.
I googled the web and found two related articles.
http://www.wintellect.com/cs/blogs/...2/13/ienumerable-lt-t-gt-and-ienumerable.aspx
http://blogs.msdn.com/brada/archive/2005/01/18/355755.aspx
But, the explanation is not satisfying.
Even though "IEnumerable<T> inherits from IEnumerable" seems follow
Liskov Substitution Principle, I believe, LSP is just a necessary
condition, not sufficent condition. And, If IEnumerable<T> doesn't
inherit from IEnumerable, no old code would be broken.
Anybody can shed some light on that?