I'm probably going about this in the wrong way, but I have a stack of Objects, and some of these can be ArrayLists. I want to be able to pop an object that is actually an ArrayList off the stack, unbox it, add something, and then pop it back on. For example:

Stack<Object> s = new Stack<Object>();
ArrayList l = new ArrayList();
Object x;
x = s.Pop();
x = (ArrayList)x; //This is the line I don't know how to do

Does anyone have an idea of how to do what I'm trying to do?

Thanks in advance :)

do in this way:

Object x;
x = s.Pop();
ArrayList al=x as ArrayList ;

Thanks, that works the way it should! Apparently what made the difference was the use of a new name for the created arrayList.