1
Answer

Deep Copy

Rich

Rich

12y
876
1
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)