If I declare 2 Array Lists, and add the second one to the first, how can I access the second one through the first. This probably dont make any sense to anybody so I'll also try it this way...
Do you see what I'm trying to do?PHP Code:void Function()
{
ArrayList List1 = new ArrayList();
ArrayList List2 = new ArrayList();
for (int x = 0; x < 10; x++)
List2.Add(x); // Fill the List with integers
List1.Add(List2); // Add List2 to List1
// Now, say I want to access the 2nd item in List2 through List1...
int y = (int)List1[0][1]; // <-- Wont compile
// However, I can create a temporary array list and get it that way.
ArrayList tmpList = new ArrayList();
tmpList = (ArrayList)List1[0]; // List1[0] is List2
// Now I can access the individual items
int y = (int)tmpList[0];
}
I'm trying to access elements of List2 by going through List1. I dont want to create a temporary ArrayList and copy to it... that seems like a waste of resources.


Reply With Quote
