Rich

Rich

  • NA
  • 84
  • 61.2k

Deep Copy

Jul 17 2012 5:39 AM
I am just learning about Deep Copy, and I am a little confused.

public Class Person
{
public string Position {get;set;}
public Tools ToolData {get;set;}
public GPS GpsData {get;set;}


public Person DeepCopy()
{
Person copy = (Person) this.MemberwiseClone();
}
}


Does the above code truly create a deep copy of all the properties in the class or am I missing a step, such as something like adding this to the code:


copy.ToolData = this.ToolData;
copy.GpsData = this.GpsData;


I want to make sure that I an truly creating a new independent object from which it was copied from.

Answers (1)