Sign in
Krzysztof Cwalina
Designing Reusable Frameworks
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Options
Blog Home
About
Email Blog Author
Share this
RSS for posts
Atom
RSS for comments
Search
Tags
Design Guidelines
General API Design
General Programming
MEF
PLP
System.Collections
System.Diagnostics Tracing
Archive
Archives
September 2011
(1)
June 2011
(1)
June 2009
(1)
March 2009
(1)
January 2009
(1)
October 2008
(2)
September 2008
(1)
August 2008
(1)
July 2008
(3)
June 2008
(2)
April 2008
(4)
March 2008
(2)
January 2008
(2)
October 2007
(3)
July 2007
(3)
June 2007
(2)
May 2007
(1)
April 2007
(2)
March 2007
(1)
February 2007
(1)
January 2007
(2)
October 2006
(1)
August 2006
(2)
July 2006
(3)
June 2006
(1)
May 2006
(1)
March 2006
(3)
February 2006
(3)
December 2005
(3)
November 2005
(5)
October 2005
(1)
September 2005
(9)
August 2005
(2)
June 2005
(3)
May 2005
(4)
April 2005
(1)
March 2005
(2)
January 2005
(1)
November 2004
(4)
October 2004
(3)
September 2004
(2)
August 2004
(1)
June 2004
(2)
May 2004
(2)
April 2004
(1)
March 2004
(3)
Why we don’t recommend using List<T> in public APIs
MSDN Blogs
>
Krzysztof Cwalina
>
Why we don’t recommend using List<T> in public APIs
Why we don’t recommend using List<T> in public APIs
Krzysztof Cwalina
26 Sep 2005 12:35 PM
Comments
30
We don’t recommend using List<T> in public APIs for two reasons.
List<T> is not designed to be extended. i.e. you cannot override any members. This for example means that an object returning List<T> from a property won’t be able to get notified when the collection is modified. Collection<T> lets you overrides SetItem protected member to get “notified” when a new items is added or an existing item is changed.
List<T> has lots of members that are not relevant in many scenarios. We say that List<T> is too “busy” for public object models. Imagine ListView.Items property returning List<T> with all its richness. Now, look at the actual ListView.Items return type; it’s way simpler and similar to Collection<T> or ReadOnlyCollection<T>.
30 Comments
Design Guidelines
,
System.Collections
,
General API Design
Blog - Comment List MSDN TechNet
Comments
Loading...
Leave a Comment
Name
Comment
Please add 2 and 5 and type the answer here:
Post