|
-
Mar 13th, 2007, 02:55 AM
#1
Fanatic Member
Re: Query on ArrayList - How to access
 Originally Posted by Rauland
Hi
I´d like to know how to access the data from an arrayList which is inside another arrayList.
Code:
//I create two arraylists.
ArrayList myArray1 = new ArrayList();
ArrayList myArray2 = new ArrayList();
//Add data to myArray1
myArray1.Add("Array1string1");
myArray1.Add("Array1string2");
//Add data to myArray2.
myArray2.Add("Array2String1");
//Add myArrayList2 to myArrayList1
myArray1.Add(myArray2);
My question is , how could I print on screen or access the data from the second array, as per:
Accessing data from index 0 and 1.
Code:
myArray1[0].ToString() +"\n";
myArray1[1].ToString();
How would I access data from index 2 ? Which is in this case an arraylist.
Thanks!
same as you access as you give in your sample. just put 2 inside the bracket.
ex. myArray1[2].ToString();
Last edited by popskie; Mar 13th, 2007 at 02:58 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|