Scott Hanselman

.NET 2.0 - What's the difference between System.Collections.Generic.Collection and System.Collections.Generic.List?

August 1, '04 Comments [1] Posted in Programming
Sponsored By

Anyone want to tell me what's the difference between System.Collections.Generic.Collection and System.Collections.Generic.List?

  • Collection<T> looks like a list, and it even has a List<T> internally.  EVERY single method delegates to the internal List<T>.  It includes a protected property that exposes the List<T>.
  • List<T> uses an array (T[]) internally and includes all this great anonymous delegate/predicate stuff like Find() and FindAll().
  • They both implement IList and ICollection.

Another weird one, Microsoft.VisualBasic still has the oddball Collection class that implements ICollection and IList.  Presumably this type exists only to help VB6 developers make the transition?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Tuesday, August 03, 2004 12:41:18 PM UTC
Anyone want to tell me what's the difference between System.Collections.Generic.Collection and System.Collections.Generic.List?
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.