Deep copy of List without serialize/deserialize
-
Is there any easier/other way to deep copy a List other than serialize to memorystream and then deserialize into a new object? The List comes from a method on a remoting server in singleton mode and fills a combobox on a UI. So i guess filling it directly with the ref would be bad practice.
If it' stuck, DO NOT pull harder!
-
Is there any easier/other way to deep copy a List other than serialize to memorystream and then deserialize into a new object? The List comes from a method on a remoting server in singleton mode and fills a combobox on a UI. So i guess filling it directly with the ref would be bad practice.
If it' stuck, DO NOT pull harder!
-
List does not interace iCloneable so i would have to
Foreach(someclass myobject in mylist){ newlist.add(myobject.clone()); }
And the class of the list needs to interface ICloneable am i right?If it' stuck, DO NOT pull harder!
Yes, you will need to create a copy of the list yourself. While, List<T> does not implement ICloneable, ArrayList does. But even so, it's only a swallow copy.
Take care, Tom ----------------------------------------------- Check out my blog at http://tjoe.wordpress.com