Geeks With Blogs
Dennis Bottjer | MVP

DoNotExposeGenericLists is a Code Analysis rule exposed within Visual Studio when List<T> is publically exposed.  For example, List<T> may be exposed through properties, methods, parameters, etc.  Why does DoNotExposeGenericLists recommend that I expose Collection instead of List? [David Kean] explains that Collection<T> is the better choice b/c it exposes 4 overidable methods.  The methods are ClearItems, InsertItem, RemoveItem and SetItem.  Events can be raised from within these four methods to provide a notification when changes are made to the Collection.  

Posted on Wednesday, May 9, 2007 1:55 PM C# , Debugging , Tips-n-Tricks | Back to top

Comments on this post: DoNotExposeGenericLists recommends Collection<T> over List<T>

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © DennisBottjer | Powered by: