<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx</link><description>Many people ask how the new.NET Framework 2.0 generic collections relate to the non-generic collections we shipped before. So, here you go. The most important types are in bold font. List&amp;lt;T&amp;gt; is basically a better ArrayList. It is optimized for speed,</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#473468</link><pubDate>Sat, 24 Sep 2005 03:33:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:473468</guid><dc:creator>tzagotta</dc:creator><description>Thanks for the summary - very informative.&lt;br&gt;&lt;br&gt;Why do you recommend to not use List&amp;lt;T&amp;gt; in public APIs?</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#473597</link><pubDate>Sat, 24 Sep 2005 19:44:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:473597</guid><dc:creator>Sean Chase</dc:creator><description>So in a public API that you are shipping, you want to use Collection&amp;lt;T&amp;gt; by deriving from it, correct?&lt;br&gt;&lt;br&gt;What about if you are not developing an API, but a layered app and you are exposing classes/collections from a Common assembly through a BL layer...is it OK to use List&amp;lt;T&amp;gt; or should you derive from List&amp;lt;T&amp;gt; and always return the derived class? I kinda like being able to return List&amp;lt;T&amp;gt;. Thoughts?</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#473873</link><pubDate>Mon, 26 Sep 2005 09:33:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:473873</guid><dc:creator>senkwe</dc:creator><description>Krzysztof, I'm curious to know why you shouldn't publically expose List&amp;lt;T&amp;gt;.&lt;br&gt;&lt;br&gt;Thanks</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#474014</link><pubDate>Mon, 26 Sep 2005 19:42:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:474014</guid><dc:creator>kcwalina</dc:creator><description>I just posted the reasons why we don't recommend List&amp;lt;T&amp;gt; in public APIs. See &lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/kcwalina/archive/2005/09/26/474010.aspx"&gt;http://blogs.msdn.com/kcwalina/archive/2005/09/26/474010.aspx&lt;/a&gt;&lt;br&gt;&lt;br&gt;Sean, using List&amp;lt;T&amp;gt; in app shared libraries may be fine as long as you can and are willing to make some breaking changes to the libraries when you discover that you need change the behavior of the collection and the only way to do it is to change it to Collection&amp;lt;T&amp;gt; and override some members. Such changes are often possible in libraries that are not distributed widely.</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#564712</link><pubDate>Thu, 30 Mar 2006 13:50:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:564712</guid><dc:creator>Philipp</dc:creator><description>Just one question: Why in god's name are there no events or virtual protected methods that allow me to get notified if an item was added or removed? That makes things so tedious. It's a shame :-(</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#564868</link><pubDate>Thu, 30 Mar 2006 17:46:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:564868</guid><dc:creator>kcwalina</dc:creator><description>Philip, I understand your question is about the collections in System.Collections.Generic namespace. The answer is that such virtual methods make would make the collections slower. To enable the exact scenario you are asking about, we added the System.Collections.ObjectModel namespace. Collections in this namespace do have virtual protected methods which you can use to get notified when an item is added or removed.</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#694757</link><pubDate>Fri, 11 Aug 2006 00:43:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:694757</guid><dc:creator>kcwalina</dc:creator><description>Somebody added the following comment to this post, but I accidentally deleted it (Sorry!). Here is that the comment said and my reply is below:&lt;br&gt;&lt;br&gt;.NET 1.1, didn't have a linked list class, so I wrote one. &amp;nbsp;I was happy to see that it would be included in 2.0. &amp;nbsp;I'm trying not to use it, though, because it doesn't implement IList. &amp;nbsp;I can guess at why you made that decision, but ... why did you make that decision?? &amp;nbsp;I always program to interfaces. &amp;nbsp;That way, if I decide to use an array or something else as my data structure, I only have to change the line in which I instantiated my list. &amp;nbsp;Developers are smart enough to know which data structures to use!&lt;br&gt;&lt;br&gt;Is there any way to override .NET's LinkedList class? &amp;nbsp;I kept getting compiler errors, so I put my linked list in the System.Collections.Generic namespace. &amp;nbsp;Now, I get compiler warnings. &amp;nbsp;In Java, I'd import the class explicitly, but I don't know what to do in .NET.&lt;br&gt;&lt;br&gt;My Reply:&lt;br&gt;We did not implement IList&amp;lt;T&amp;gt; on LinkedList because the indexer would be very slow. If you really need the interface, you probably can inherit from LinkedList&amp;lt;T&amp;gt; and implement the interface on the subtype.</description></item><item><title>Riguardo List</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#739450</link><pubDate>Mon, 04 Sep 2006 16:28:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:739450</guid><dc:creator>Luke's Blog</dc:creator><description /></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#743548</link><pubDate>Thu, 07 Sep 2006 04:15:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:743548</guid><dc:creator>Jimmy</dc:creator><description>Great post -- I look this up all the time :)&lt;br&gt;What do you say that ICollection has no generic equivalent (or, at least, you suggest using IEnumerable&amp;lt;&amp;gt; instead of ICollection&amp;lt;&amp;gt;)? </description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#744640</link><pubDate>Thu, 07 Sep 2006 19:36:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:744640</guid><dc:creator>kcwalina</dc:creator><description>ICollection is immutable (no members to change the contents of the collection). ICollection&amp;lt;T&amp;gt; is mutable. This is a substantial difference making the interfaces similar only in their name. One the other hand ICollection and IEnumerable&amp;lt;T&amp;gt; differ by very little.</description></item><item><title>Les Interfaces de collections</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#772895</link><pubDate>Wed, 27 Sep 2006 01:47:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:772895</guid><dc:creator>Code is poetry</dc:creator><description>On utilise tous les jours les interfaces IEnumerable, ICollection, IList quand on d&amp;amp;#233;veloppe en .Net,...</description></item><item><title>Diff&amp;#233;rences entre IList non-g&amp;#233;n&amp;#233;rique et IList g&amp;#233;n&amp;#233;rique</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#861937</link><pubDate>Mon, 23 Oct 2006 13:52:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:861937</guid><dc:creator>Code is poetry</dc:creator><description>&lt;p&gt;On utilise tous les jours les interfaces IEnumerable, ICollection, IList quand on d&amp;#233;veloppe en .Net,&lt;/p&gt;
</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#1810602</link><pubDate>Mon, 05 Mar 2007 19:15:02 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1810602</guid><dc:creator>Nital Patel</dc:creator><description>&lt;p&gt;I am using CollectionBae as below. How can I use generics instead?&lt;/p&gt;
&lt;p&gt;	public class ItemCollection : CollectionBase&lt;/p&gt;
&lt;p&gt;	{&lt;/p&gt;
&lt;p&gt;		public ItemCollection.ItemInfo this[ int index ]&lt;/p&gt;
&lt;p&gt;		{&lt;/p&gt;
&lt;p&gt;			get { return (ItemCollection.ItemInfo)List[ index ]; }&lt;/p&gt;
&lt;p&gt;			set { List[ index ] = value; }&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#1811439</link><pubDate>Mon, 05 Mar 2007 21:38:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1811439</guid><dc:creator>kcwalina</dc:creator><description>&lt;p&gt;Nital,&lt;/p&gt;
&lt;p&gt;You can use Collection&amp;lt;ItemInfo&amp;gt; instead of your subclass of CollectionBase.&lt;/p&gt;
</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#1911809</link><pubDate>Mon, 19 Mar 2007 12:05:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1911809</guid><dc:creator>Alessandro</dc:creator><description>&lt;p&gt;hi Krzysztof, nice post. Thanks.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Alessandro&lt;/p&gt;</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#3407351</link><pubDate>Tue, 19 Jun 2007 18:30:13 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3407351</guid><dc:creator>Enrique Tron</dc:creator><description>&lt;P&gt;Excelent solution!... a friend did some workaround trying to create this class!!... &lt;/P&gt;
&lt;P&gt;Good things about frameworks=a lot of stuff already done!, &lt;/P&gt;
&lt;P&gt;Bad thing=you should know where it is&lt;/P&gt;
&lt;P&gt;happyCoding&lt;/P&gt;</description></item><item><title>Speed Test: Generic List vs. ArrayList</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#7010583</link><pubDate>Mon, 07 Jan 2008 02:30:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7010583</guid><dc:creator>VishwaMohan.NET</dc:creator><description>&lt;p&gt;Speed Test: Generic List vs. ArrayList&lt;/p&gt;
</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#7142858</link><pubDate>Thu, 17 Jan 2008 21:48:15 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7142858</guid><dc:creator>AdamL</dc:creator><description>&lt;p&gt;Why do Generics provide little to no speed-up over non-Generics, and are also at least 2x slower then running the same code (without Generics) in .NET 1.1? &lt;/p&gt;
&lt;p&gt;I'm talking about a program that stores database information in Hashtables. One of these hashes strings to ArrayLists and there are around 10,000 key, value pairs. The other hashtables are similar in size. &lt;/p&gt;</description></item><item><title>Speed Test: Generic List vs. ArrayList</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#7427196</link><pubDate>Mon, 04 Feb 2008 08:20:25 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7427196</guid><dc:creator>Vishwamohan.NET</dc:creator><description>&lt;p&gt;Speed Test: Generic List vs. ArrayList&lt;/p&gt;
</description></item><item><title>System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#8194502</link><pubDate>Fri, 14 Mar 2008 07:23:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8194502</guid><dc:creator>Vincent Yang</dc:creator><description>&lt;p&gt;ref:&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspxPublished23September0508"&gt;http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspxPublished23September0508&lt;/a&gt;...&lt;/p&gt;
</description></item><item><title>总结：C# Collections</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#8665706</link><pubDate>Sun, 29 Jun 2008 05:52:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8665706</guid><dc:creator>VeryDxZ</dc:creator><description>&lt;p&gt;（准确的说是.Net的。但我只对C#比较熟，像VB.Net之类的还有自己以前的一些集合类带过来暂不考虑。下面以.Net2.0的BCL为准，至少它们到3.5都没大变化。） Reference...&lt;/p&gt;
</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#8671663</link><pubDate>Mon, 30 Jun 2008 19:11:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8671663</guid><dc:creator>Maciey</dc:creator><description>&lt;p&gt;Anybody knows why below is not working???&lt;/p&gt;
&lt;p&gt;BO2 inherits from BO and M1 shall accept this collection as well. Doesnt it?&lt;/p&gt;
&lt;p&gt;	public class BO {}&lt;/p&gt;
&lt;p&gt;	public class BO2 :BO {}&lt;/p&gt;
&lt;p&gt;	public class BOC &amp;lt;BO&amp;gt; : BindingList&amp;lt;BO&amp;gt; &amp;nbsp;{}&lt;/p&gt;
&lt;p&gt;	public class Client {&lt;/p&gt;
&lt;p&gt;		public void M1 (BOC &amp;lt;BO&amp;gt; BOCollection) {&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;		public void M2 () {&lt;/p&gt;
&lt;p&gt;			M1( new BOC&amp;lt;BO2&amp;gt;() );&lt;/p&gt;
&lt;p&gt;		}&lt;/p&gt;
&lt;p&gt;	}&lt;/p&gt;</description></item><item><title>re: System.Collections vs. System.Collection.Generic and System.Collections.ObjectModel</title><link>http://blogs.msdn.com/kcwalina/archive/2005/09/23/Collections.aspx#9373783</link><pubDate>Sat, 24 Jan 2009 10:48:24 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9373783</guid><dc:creator>Sandip</dc:creator><description>&lt;p&gt;MCTS self-paced exam book lists SortedDictionary as non-generic counterpart of Generic SortedDictionary class. This is not true as I searched the objects under Object Browser in VS 2005 and also you mentioned N/A against its non-generic class. So this blog is very informative and helps.&lt;/p&gt;</description></item></channel></rss>