Arraylist deep copy

G

Guest

Hi,

I would like to ask if the constructor ArrayList(ICollection c) performs the
deep or shallow copy of "c" collection.

If it perfoms just shallow copy, is there any method for doing a deep one?

Thanks,

Lubomir
 
N

Nicholas Paldino [.NET/C# MVP]

Lubomir,

It performs a shallow copy. It will not perform a full copy of the
items in the collection when bringing them over.

.NET doesn't really have a mechanism to distinguish between a deep and a
shallow copy operation.

Hope this helps.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Shallow. IIRC none of the collection classes in the framework does a deep
copy, even if the collected type support ICloneable.

You would have to inherit from the collection you want and implement a deep
copy method. For this the collected class should implement ICloneable
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top