VB 2010 – List Initializer

I’ve been using VB.NET for about a year now (I was exclusively a C# developer before that) and one thing that always annoyed me was not being able to initialize my lists at the time that I declared them, the way I could in C#.  They added this functionality in VB 10, so this is how you do it:

Dim customers As New List(Of String) From {"Tom", "Bob", "John", "Lisa"}

Leave a Reply

Your email address will not be published. Required fields are marked *