tags:

views:

100

answers:

2

How is the following translated in VB.net:

var theVar = new List<string>{"one", "two", "three"};
+3  A: 

Collection initializers are only available in VB.Net 2010, released yesterday:

Dim theVar = New List(Of String) From { "one", "two", "three" }
SLaks
+1  A: 

Use this syntax for VB.Net 2005/2008 compatibility:

Dim theVar As New List(Of String)(New String() {"one", "two", "three"})

Although the VB.Net 2010 syntax is prettier.

Prutswonder
This is not the same. (It creates an array and calls a constructor overload)
SLaks
Not the same, but the best option until you get VB.Net 2010
Kibbee
Hmm, the <2010 syntax doesn't really offer any added value over just splitting it over two lines. It is the answer to my question though. Thx
borisCallens