Dynamic Arrays in C#
Submitted By:
Unknown
Rating:





(
Rate It)
Share:
By Email
Visit
Description
This article shows how to create dynamic arrays in C# (.NET).
Comments (34)
Good One




Posted by: Rami Reddy MVB on Tuesday, March 25, 2003
Good Article
Useful




Posted by: Karen on Tuesday, January 06, 2004
Very useful article!
Only 1 remark. This:
string[] aFoo = new string[9];
assigns to array aFoo 9 elements, not 10.
Respect, yes!
very helpful and not coplex




Posted on Saturday, April 17, 2004
I know its a simple topic but very helpful.
Eventually!




Posted by: Gary Hall on Friday, August 13, 2004
I spent ages looking for C# dynamic arrays tutorials, this explanation came in very handy.
Ta.
very nice




Posted on Monday, March 14, 2005
simple, effective, great..
Very good




Posted on Tuesday, January 17, 2006
Very helpful - thanx
Just What Was Needed




Posted by: Jim on Thursday, March 09, 2006
Bump. Very useful. Short and sweet.
Answered exactly what I was looking for!




Posted on Wednesday, May 02, 2007
Very well written
excellent




Posted on Friday, August 24, 2007
It's very useful
This is not what the title says
Posted on Thursday, August 30, 2007
it is supposed to be a tutorial teaching how to create dynamic arrays and not how to escape creating dynamic arrays and using Arraylist instead. I give u a 0
upperbound




Posted by: jay on Wednesday, September 19, 2007
If you use an array, there is GetUpperBound method. Is there any property/method in arraylist?
Extremely Helpful and easy!




Posted on Wednesday, November 14, 2007
Good Article!
C# Nuub




Posted on Thursday, November 15, 2007
Thank you for explaining dynamic arrays in C#. I've been looking for a c++ vector replacement and I think I've found it in ArrayList!
Excellent Resource!




Posted by: Andrew on Friday, February 29, 2008
Thanks a lot for this tutorial. It helped me a lot!
Very Good Article




Posted by: Vanessa on Tuesday, March 25, 2008
This is a very good article and very easy of understand. I recommended.
Very useful article




Posted on Friday, May 30, 2008
This article was exactly the information I was looking for, including the explanations and code samples. Excellent!
Good, but better to use List<T> now instead of ArrayList




Posted by: Jink on Friday, August 15, 2008
Better performance, avoids boxing.
dyhy




Posted by: htyh on Thursday, September 18, 2008
hhhh
Dynamic?




Posted by: Drew Perrett on Monday, October 06, 2008
There is nothing dynamic about this array creation method, just hard coded rubbish.
Dynamic? 2




Posted by: Noel on Wednesday, January 07, 2009
Agreeing with Dynamic? 1
Dynamic? 2




Posted by: Noel on Wednesday, January 07, 2009
Agreeing with Dynamic? 1
Looks good!




Posted by: Roger on Tuesday, February 10, 2009
What hard-coded about this? It does what it advertises - makes a dynamic list of things. Whether you call that an array, an arraylist, or your Grandma's shoes, the result is the same - a list of stuff with no defined start or end point. Well done!
nonsense




Posted by: stefko on Thursday, March 05, 2009
It is not an array, it is a collection of objects.
thank you




Posted by: meysam rahimi on Friday, March 06, 2009
thank you for your describtion. that was so fantastic.
dynamic string array




Posted by: m behrens on Tuesday, June 23, 2009
its fine but
here is my version of pascal's setLength for C#.
It makes string arrays not only larger, but truncates them also.
Feel free to use it and be aware of the "ref" directive needed in your call.
private void setLength(ref string[] arr, int newLength)
{
if (arr == null) arr = new string[newLength]; else
{
string[] tempArr = new string[newLength];
for (int i = 0; i < newLength; i++)
if (i < arr.Length) tempArr[i] = arr[i];
else tempArr[i] = "";
arr = new string[newLength];
for (int i = 0; i < newLength; i++) arr[i] = tempArr[i];
}
}
This article perfect




Posted by: Hasan on Sunday, July 19, 2009
Good job man. Thanks a lot
good one




Posted by: umesh on Friday, January 15, 2010
This article perfect
thanks..very useful article




Posted by: suresh on Friday, April 02, 2010
fail




Posted by: fail on Friday, June 25, 2010
the goddamn link doesn't even work!
404 Error...Link is down




Posted by: Eric Layne on Monday, July 19, 2010
404 Error...Link is down
Old link dead copy following link. I just googled




Posted by: ramkumar on Tuesday, August 03, 2010
http://authors.aspalliance.com/remas/ASP.NET/VFAQNET/DynamicArrays/
this sucks




Posted by: Programmer's hell on Monday, November 15, 2010
You used a link and now the link is down and all you have a a bunch of posts saying how good this is. If this is typical of programmers heaven then they should rename themselves programmes hell
dead link




Posted by: Pierre on Thursday, February 24, 2011
I concur with the previous poster. Please post solutions in the forum, not links to solutions, unless it is within the same forum.
Dead Link




Posted by: Matt on Sunday, February 10, 2013
Definately Programmers Hell.
I Declare Fudgemuffins.
Add Your Rating