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"})
为了将项目添加到列表的中间,请使用插入
插入将把该项目放置在索引处,并对其余项目重新编号
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"