Hi,
Here is a piece of code where I have a class by name SomeClass
array1 consists of objects of the type SomeClass
array2 is intialized with contents of array1.
Why does changes made to the object of array2 affect the same object in
array1.
The o/p for the following should be just '1' but why is it '11'?
ArrayList array1 = new ArrayList();
array1.Add(new SomeClass("1"));
array1.Add(new SomeClass("2"));
ArrayList array2 = new ArrayList();
array2 = array1;
array1.Add(new SomeClass("3"));
SomeClass al = (SomeClass) array2[0];
al.AlName = "11";
SomeClass newObj = (SomeClass) array1[0];
MessageBox.Show (newObj.AlName);