开发者

Inline list initialization in VB.NET [duplicate]

开发者 https://www.devze.com 2022-12-26 10:05 出处:网络
This question already has answers here: Closed 10 years 开发者_如何学Pythonago. Possible 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

精彩评论

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