將項新增到列表

Dim aList as New List(Of Integer)
aList.Add(1)
aList.Add(10)
aList.Add(1001)

要一次新增多個專案,請使用 AddRange 。始終新增到列表的末尾

Dim blist as New List(of Integer)
blist.AddRange(alist) 

Dim aList as New List(of String)
alist.AddRange({"one", "two", "three"}) 

要將專案新增到列表中間,請使用“ 插入”

Insert 會將專案放在索引處,並重新編號其餘專案

Dim aList as New List(Of String)
aList.Add("one")
aList.Add("three")
alist(0) = "one"
alist(1) = "three"
alist.Insert(1,"two")

新產出:

alist(0) = "one"       
alist(1) = "two"
alist(2) = "three"