你如何在 VB.NET 中创建一个新数组?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/990512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 14:15:33 来源:igfitidea点击:
How do you create a New array in VB.NET?
提问by TheFlash
Possible Duplicate:
VB.Net Initialising an array on the fly
可能的重复:
VB.Net 动态初始化数组
This maybe a stupid question, but its got me exasperated. How do I declare a new array inline? Is this possible? I've tried all of the following and they all don't work.
这可能是一个愚蠢的问题,但它让我很生气。如何声明一个新的内联数组?这可能吗?我已经尝试了以下所有方法,但它们都不起作用。
myVar = {"a", "b", "c"}
myVar = Array(3)
myVar = Array("a", "b", "c")
myVar = New Array()
myVar = New Array(3)
myVar = New Array("a", "b", "c")
回答by jitter
Either
任何一个
Dim strings = New String() {"a", "b", "c"}
or
或者
Dim strings() As String = {"a", "b", "c"}
should work
应该管用