简体   繁体   中英

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? 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) . Then you can just call the Add method.

For example:

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

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

Array.Concat({Item}).ToArray

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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