简体   繁体   English

Visual Basic数组推送

[英]Visual Basic Array Push

I am currently iterating through a loop and redimensionalising my array every time I need to add a value (as you can imagine this takes some time for a redim every loop) is there a way I can implement a push similar to ruby or java? 我正在迭代循环并在每次需要添加值时对我的数组进行重新维度化(因为你可以想象这需要花费一些时间来重新设置每个循环)是否有一种方法可以实现类似于ruby或java的推送? This would need to save the processing time needed to redimensionalise the array every time I need to add a value to it. 每次我需要为其添加值时,这需要节省重新定义数组所需的处理时间。

Cheers Martin 干杯马丁

You'd be better off using a List (Of Type) . 你最好使用List (Of Type) Then you can just call the Add method. 然后你可以调用Add方法。

For example: 例如:

Dim foo As New List(Of String)
foo.Add("Bar")

您可以使用仅包含新项目的数组或多个数组来连接数组。

Array.Concat({Item}).ToArray

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM