In article <ew**************@TK2MSFTNGP11.phx.gbl>, Marc Lefebvre wrote:
there is an easy way to make a deep copy of an arraylist ?
suppose I have an arraylist of COptions implements ICloneable
I have need to overload the Clone() methode of a derived ArrayList
(OptionsArrayList)
And Overload the Clone() methode of my COptions
There is an otherway to do deep copy ?
Thank's
Marc
Marc,
You could make sure the objects in it are marked serializable. Then you
can serialize the arraylist to a memrory stream, and then deserialize it.
You will then have a deep copy :)
<Serializable()> _
Class TheClass
' make sure all the members are serializable :)
...
End Class
dim arr as new arraylist
for i as integer = 1 to 100
arr.add(new theclass)
next
dim mem as new memroystream
dim bf as new binaryformatter
bf.serialize(mem, arr)
mem.seek(seekorigin.begin) ' put the pointer back or you get an error..
dim newarr as arraylist = directcast(bf.deserialize(mem), theclass)
--
Tom Shelton [MVP]