July 2015
Intermediate to advanced
1300 pages
87h 27m
English
The Visual Basic language implements a feature known as collection initializers. 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 typesDim listOfIntegers As New List(Of Integer) From {1, 2, 3, 4}
The preceding code produces the same result as the following:
Dim listOfIntegers As New List(Of Integer)listOfIntegers.Add(1)listOfIntegers.Add(2)listOfIntegers.Add(3)listOfIntegers.Add(4)
You can easily ...
Read now
Unlock full access