Geeks With Blogs
Greg Young Greg.ToString()

Eralier I posted (and deleted) about the Queue class not implementing ICollection from some research this is by design.


"Some collections that limit access to their elements, like the Queue class and the Stack class, directly implement the ICollection interface."

If you look, the interfaces are also very different from each other in what they include. The generic one includes methods such as ... Add, Remove, and Clear which do not exist on the non-generic ICollection.

So conclusion .. Queue is correct but I have to say that having the generic and non-generic ICollections that represent completely different things is a bit confusing at best :-/

Posted on Tuesday, May 9, 2006 10:19 PM | Back to top

Comments on this post: ICollection and ICollection<>

# re: ICollection and ICollection<>
Requesting Gravatar...
I don't want to cast it or have to explicitly state the type. I just want to use var and have clean code. As far as that goes, ICollection<string> counter is the same as var counter = (ICollection<string>), and doesn't solve the issue .
Thank you.
i hope you also like it.....
Free Nifty Tips
Left by Intraday Share Tips on Mar 15, 2011 2:50 AM

Your comment:
 (will show your gravatar)

Copyright © Greg Young | Powered by: