列表可以根据需要使用任何数据类型填充,格式为
Dim aList as New List(Of Type)
例如:
创建一个新的空字符串列表
Dim aList As New List(Of String)
创建一个新的字符串列表,并填充一些数据
VB.NET 2005/2008:
Dim aList as New List(Of String)(New String() {"one", "two", "three"})
VB.NET 2010:
Dim aList as New List(Of String) From {"one", "two", "three"}
-
VB.NET 2015:
Dim aList as New List(Of String)(New String() {"one", "two", "three"})
注意:
如果在运行代码时收到以下消息:
你调用的对象是空的。
确保您声明为Newie,或者如果声明时不带,请确保将列表设置为新列表-Dim aList as New List(Of String)NewDim aList as List(Of String) = New List(Of String)