<< Back to the snippet list

Collection initializers

Published: 05 May 2008 By Granville Barnett

One of my personal favourite new features in C# 3.0 is the ability to concisely initialize the items of a collection using collection initializers. One thing to note is that every item of the type of the collection you define within the curly braces calls that collections Add method. You can see that the post C# 3.0 version is more concise, and I believe more readable than the more verbose older syntax.

C# 3.0 Collections

Please login to leave a comment.