S
Steven Blair
I need to perform a Deep Copy on an ArrayList.
I wrote a small sample app to prove this could be done:
ArrayList a = new ArrayList();
ArrayList b = new ArrayList();
a.Add("Hello");
b = (ArrayList) a.Clone();
a[0] = "World";
This appears to work fine. However, when I try it in my application,
both ArrayLists point to the same memory.
Each element in my ArrayList is a custom class I have written, so I am
wondering would this have any impact on the call to Clone() ?
At a high level, what I need to do is create a very large structure once
on startup (the ArrayList will be static) and when each request comes in
from a client, I take a deep copy of the structure and allow each client
their own working copy. This would cut down a massive amoutn of
processing on my part.
Can anyone help?
Steven
I wrote a small sample app to prove this could be done:
ArrayList a = new ArrayList();
ArrayList b = new ArrayList();
a.Add("Hello");
b = (ArrayList) a.Clone();
a[0] = "World";
This appears to work fine. However, when I try it in my application,
both ArrayLists point to the same memory.
Each element in my ArrayList is a custom class I have written, so I am
wondering would this have any impact on the call to Clone() ?
At a high level, what I need to do is create a very large structure once
on startup (the ArrayList will be static) and when each request comes in
from a client, I take a deep copy of the structure and allow each client
their own working copy. This would cut down a massive amoutn of
processing on my part.
Can anyone help?
Steven