问题描述
就像初始化一样: 我们喜欢:
Dim a() as integer = {1,2,4,6}
如果我想打印数组列表,它将是 1,6 作为输出 但是我怎么能取任何值,即 n 值来打印 n 值作为输出。
解决方法
在我看来,最好的办法是将数组中的 n 个元素添加到第二个数组中,然后打印出来:
Dim a() as integer = {1,2,3,4,6}
Dim b as new list(of integer)
' Where n is the total number of elements you want to print.
For counter As integer = 0 To n
b.Add(a(counter))
Next
PrintItems(b)
我已经将近 10 年没有在 VB 中工作了,如果我的代码不是 100% 正确,我深表歉意。