Array question

  • Thread starter Thread starter Arjen
  • Start date Start date
A

Arjen

Hello,

I want to make an array but I don't know the future size.
This can be 10 but also 100 elements.

How can I make an array... and just put in what I need?
After that I want to loop throug my array.

How can I do that?
Thanks!
 
Arjen said:
Hello,

I want to make an array but I don't know the future size.
This can be 10 but also 100 elements.

How can I make an array... and just put in what I need?
After that I want to loop throug my array.

How can I do that?
Thanks!

Try the ArrayList class Arjen. It has .Add and .Remove methods so you dont
need to worry about the number of elements, .NET does it for you.

ArrayList myArrayList = new ArrayList;

myArrayList.Add(new Person());
myArrayList.Add(new Person());

foreach (Person p in myArrayList)
{
}
 
Okay, thanks!

I just found it.

Arjen





joseph.inglis said:
Try the ArrayList class Arjen. It has .Add and .Remove methods so you dont
need to worry about the number of elements, .NET does it for you.

ArrayList myArrayList = new ArrayList;

myArrayList.Add(new Person());
myArrayList.Add(new Person());

foreach (Person p in myArrayList)
{
}
 
i did wonder why you hadnt found it, even with a minimal search on the
subject.

brownie points awarded for getting it on your own though ;-)

Tam
 
Back
Top