开发者

Inline list initialization in VB.NET [duplicate]

This question already has answers here: Closed 10 years 开发者_如何学Pythonago.

Possible Duplicate:

Collection initialization syntax in Visual Basic 2008?

How is the following C# code translated to VB.NET?

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


Collection initializers are only available in VB.NET 2010, released 2010-04-12:

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜