VB.NET 10 : Collection Initializer

VB.NET 10 : Collection Initializer

  • Comments 1

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!!!

Leave a Comment
  • Please add 6 and 2 and type the answer here:
  • Post
  • thanks!!!

Page 1 of 1 (1 items)