public class Person { public string Name { get; set; } public Address Address { get; set; } } public class Address { public string City { get; set; } public string State { get; set; } }
var originalPerson = new Person { Name = "John Doe", Address = new Address { City = "New York", State = "NY" } }; var copiedPerson = Pen.Clone.DeepCopy(originalPerson);
public class Person { public string Name { get; set; } public int Age { get; set; } public Person Clone() { return (Person)this.MemberwiseClone(); } }
var originalPerson = new Person { Name = "John Doe", Age = 35 }; var clonedPerson = originalPerson.Clone();In both examples, Pen Clone is used to create a copy of an object. The package library used is Pen Clone.