Collections: Does 'Add' make a deep copy?

  • Thread starter Thread starter Steve Hiemstra
  • Start date Start date
S

Steve Hiemstra

Hi All,

When I 'Add' an 'object' to a System.Collection (ArrayList, HashTable,...)
does it just put a 'reference' to the object in the Collection, or is it a
'deep copy' (a new instance of the object)?

SteveH
 
When I 'Add' an 'object' to a System.Collection (ArrayList, HashTable,...)
does it just put a 'reference' to the object in the Collection, or is it a
'deep copy' (a new instance of the object)?

A reference (the object is not copied or cloned)
 
Mehdi said:
A reference (the object is not copied or cloned)

Which gives you the choice of calling Add(o.Clone()) if you didn't want a
reference to a shared object.
 

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

Back
Top