I'm having trouble with a class that accepts an ArrayList as a
parameter. The code looks something like this:
ArrayList arrayOne = new ArrayList();
arrayOne.Add("Hello ");
arrayOne.Add("There!");
someClass sc1 = new someClass(arrayOne);
arrayOne.Clear();
arrayOne.Add("Oh ");
arrayOne.Add("No!");
someClass sc2 = new someClass(arrayOne);
If I step through the code, sc1 is created just fine with the
appropriate contents of arrayOne. However, one I reach the Clear()
call, the contents of the ArrayList inside of sc1 change and "Oh No!"
is then placed inside. In the end I have sc1 and sc2 with identical
ArrayLists. I'm sure there's something obvious I'm missing, any help
would be greatly appreciated.