内联初始化列表在VB.NET [英] Inline list initialization in VB.NET

查看:115
本文介绍了内联初始化列表在VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  

可能重复:
  <一href="http://stackoverflow.com/questions/85892/collection-initialization-syntax-in-visual-basic-2008">Collection在Visual Basic 2008初始化语法?

下面的C#code如何转换到VB.NET?

  VAR theVar =新的名单,其中,串&GT; {一,二,三};
 

解决方案

使用这种语法 VB.NET 2005/2008兼容性:

 昏暗theVar作为新的列表(串)(新的String(){一,二,三化})
 

虽然 VB.NET 2010语法是prettier。

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"};

解决方案

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.

这篇关于内联初始化列表在VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆