This can be used to clone an object however this is a
C++ term, this allows you to specify an object to create the data from, it would not be very idiomatic for a
C# developer so I don’t feel its the best approach for me as a .Net Developer.
Would require each custom type to have a copy constructor to allow traversing of the tree so the copy is done recursively. If you want to clone rather look at the suggestions under the creational Prototype Pattern.
Address which have copy constructors:
public class Person
This will work as strings are immutable.
var carl = new Person("Carl", new Address("Sale Street", 66));
Output would be:
FirstName: Carl, Address: StreetName: Sale Street, HouseNumber: 66
- [PrototypePattern/CopyConstructorDemo.cs](https://github.com/carlpaton/Boilerplate/blob/master/.Net Core Console Application/PatternsAndPrinciples/PrototypePattern/CopyConstructorDemo.cs)