VB.NET 10 : Collection Initializer
Another useful feature which was missing in VB.Net 9 is available in Visual Studio 2010. This provides option to declare and initialize with series of values with the keyword Form.
Dim myList As New List(Of Integer) From {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
For Each i In myList
Console.WriteLine(i)
Next
Similarly you also may initialize the collection like Dictionary.
Dim myDic As New Dictionary(Of Integer, String) From {{1, "One"}, {2, "Two"}}
Namoskar!!!
Comments
- Anonymous
April 16, 2013
thanks!!!