vb.net 在 Visual Basic 2010 中将数组重置为默认值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21643228/
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
Reset an Array to Default in Visual Basic 2010
提问by Marcel
What is the code to reset an array to its default state so that all the elements are erased?
将数组重置为其默认状态以便擦除所有元素的代码是什么?
回答by har07
you can try Array.Clearmethod :
你可以试试Array.Clear方法:
Array.Clear(myArray, 0, myArray.Length)
that will revert value of each array element to default (0, false, or Nothingdepending on the element type as described in the link above).
这会将每个数组元素的值恢复为默认值(0, false, 或Nothing取决于上面链接中描述的元素类型)。
Another option is to use Erase
另一种选择是使用擦除
Erase myArray
that will turn myArrayvariable to Nothing.
这将把myArray变量变成Nothing.
回答by VBGod
System.Array.Clear(Array, 0, Array.length)
You can switch 0 to Nothing it depends on the variable in your array
您可以将 0 切换为 Nothing 这取决于数组中的变量
回答by aksu
You can use Erase.
您可以使用Erase.
Erase YourArray

