Basic array question

  • Thread starter Thread starter JJ
  • Start date Start date
J

JJ

Hi all!

I want to add array elements afther creation of it, something like this:

int[] i = {1, 2, 3} // i.Length is now 3

i[3] = 4; // out of range exception!

How can I solve this problem?

Regards,

Vincent
 
Use a System.Collections.ArrayList rather than an array.
That way, you can just use Add/Remove methods to add/remove items.
 
Back
Top