|
-
May 1st, 2007, 02:03 PM
#1
Thread Starter
Frenzied Member
[2.0] redim array in C#?
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?
-
May 1st, 2007, 02:27 PM
#2
Re: [2.0] redim array in C#?
-
May 1st, 2007, 04:31 PM
#3
Frenzied Member
Re: [2.0] redim array in C#?
or an ArrayList
But List<T> is cooler. Especially with classes
-
May 1st, 2007, 04:57 PM
#4
Re: [2.0] redim array in C#?
You shouldn't use ArrayList in .NET 2.0, it's needlessly inefficient.
-
May 1st, 2007, 05:15 PM
#5
Re: [2.0] redim array in C#?
If you really need to use an array, then .NET 2 does have 'Resize' method on the Array class.
-
May 1st, 2007, 06:34 PM
#6
Re: [2.0] redim array in C#?
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:
I need to remove and add things constantly
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.
-
May 3rd, 2007, 02:19 AM
#7
Registered User
Re: [2.0] redim array in C#?
you can resize your array by using the following code.
vb Code:
Array[] a;
a = new Array[100];
-
May 3rd, 2007, 02:23 AM
#8
Re: [2.0] redim array in C#?
That will erase it all, though.
Also, that code is an array of arrays.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|