May 2010
Intermediate to advanced
1272 pages
61h 18m
English
Visual Basic 2010 introduces a new language feature known as collection initializers. Basically this feature works like the object initializers, except that it is specific for instantiating and populating collections inline. To take advantage of collection initializers, you need to use the From reserved keyword enclosing items within brackets, as demonstrated in the following code:
'With primitive types Dim listOfIntegers As New List(Of Integer) From {1, 2, 3, 4}
The preceding code produces the same result as the following:

You can easily understand how collection initializers enable writing less code that’s ...
Read now
Unlock full access