Clone

  • Thread starter Thread starter Semut
  • Start date Start date
S

Semut

Hello,


When do I need to use the Clone function? I am aware that instances that
inherited Forms.Control will somehow be of reference types instead of value
types. I have tested that ArrayList behave the same as well. Anyway that I
could know when I need Clone when I do not want to modify the original
content that I passed in to my function?


thank you.
 
You could refer to this article http://www.codeproject.com/dotnet/Clone.asp

Unless a particular type provides a deep cloning implementation by
implementing IClonable, the cloning would be shallow when
Object.MemberwiseClone is called. I dont think Form or Control classes
implement IClonable (it wouldnt make sense either). ArrayList does and hence
the cloning in this case is deep.
 
Back
Top