Welcome to MSDN Blogs Sign in | Join | Help

Wriju's BLOG

.NET and everything
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!!!

Posted: Wednesday, October 14, 2009 2:18 AM by wriju

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker