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.
 
Back
Top