Collection Initializers
Added in .NET 3.5
This provides a shortened syntax that enables you to create a collection and populate it with an initial set of values
var myChildren = new List<Person>
{
new Person { Name = "Lisa"; }
new Person { Name = "Richard"; }
}
List<int> mylist = new List<int> {0,1,2,3,4,5};
This was added to VB.Net in Visual Studio 2010.
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext