Solved

Accessing items in ArrayList of ArrayLists

Posted on 2006-11-29
1
769 Views
Last Modified: 2008-02-01
Hi

I have an ArrayList (al) and I add Arraylists to it.
Is there a simple way to get the first item of the first arraylist?
Or the sixth item of the first arraylist?
thanks
HMC
0
Comment
Question by:hmcgeehan
1 Comment
 
LVL 2

Accepted Solution

by:
BogdyPtr earned 20 total points
ID: 18035784
Try ((ArrayList)al[0])[0] to get first element of the first ArrayList.
A more elegant solution is to use generic List class instead of the main array list:

List<ArrayList> arrays;

...

arrays[1][2] = 5;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now