multidimensional ArrayList?

  • Thread starter Thread starter Daves
  • Start date Start date
The existing ArrayList cannot be used as a
multidimensional array directly, however you could make it
act like one if you had it store ArrayLists... so your
code would look something like:

ArrayList myList = new ArrayList();
myList.Add( new ArrayList() );
myList.Add( new ArrayList() );

((ArrayList)myList[0])[1].Add(dataObj);

Quite an ugly solution I know. If the ugly typecasting and
hacking isn't your thing on the surface, your only other
choice would be to build your own class.
 
is it possible? if so - how would you do it?

No, but you can store ArrayList objects inside an ArrayList (making it
somewhat like a jagged array).



Mattias
 
Mattias,
No, but you can store ArrayList objects inside an ArrayList (making it
somewhat like a jagged array).

Is than the answer not Yes.

:-)

I know that it looks terrible all that casting.

Cor
 

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

Back
Top