Well I got an array that I need to remove and add things constantly and the size is gonna vary so just giving it a bunch of slots wont work. is there a fast way to add to an array?
Printable View
Well I got an array that I need to remove and add things constantly and the size is gonna vary so just giving it a bunch of slots wont work. is there a fast way to add to an array?
Use a List<T>.
or an ArrayList
But List<T> is cooler. Especially with classes :D
You shouldn't use ArrayList in .NET 2.0, it's needlessly inefficient.
If you really need to use an array, then .NET 2 does have 'Resize' method on the Array class.
As David says, the Array class now has a Resize method, which I'd choose to use in VB too. Having said that, you should only use an array and its Resize method if you will be resizing very infrequently. From this:you should definitely use a List. Note that the List class is implemented using an internal array, but the class handles the resizing in as efficient a way as possible. To achieve the same result you'd have to needlessly write a fair bit of code.Quote:
I need to remove and add things constantly
you can resize your array by using the following code.
vb Code:
Array[] a; a = new Array[100];
That will erase it all, though.
Also, that code is an array of arrays.