Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
打扰一下,我想通过 vb.net 创建一个数组,我该怎么做?
我想用一个for循环来完成它。
这是一个数组:
[1,2,3,4,5,6,7,8,9,.....,100]
您不必使用 For 循环,因为您只需要序列号。这是一种单线解决方案:
Dim collection() As Integer = Enumerable.Range(1, 100).ToArray()
小提琴:现场演示
否则,如果您仅限于使用 For/Next,则创建一个设置上限的集合,然后从 1 循环到 100:
Dim collection(99) As Integer For c As Integer = 1 To 100 collection(c - 1) = c Next