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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Pointers to arrays 5
Shape Arrays VBA 0
Large arrays in c# 9
?? Basic C# Language Questions ?? 14
Maximum Array int is 330 M, not 2.1 billion 18
array in struct 3
Reference into an array 5
Multi-dimensional arrays 2

Back
Top