// change to main to run. public static void none(string[] args) { var john = new Person2(new[] { "John", "Smith" }, new Address2("London Road", 123)); // just copying and changing the reference. //var jane = john; //jane.names[0] = "Jane"; Console.WriteLine(john); var jane = new Person2(john); jane.address.houseNumber = 321; Console.WriteLine(jane); Console.WriteLine(john); }
// Copy Constructor public Person2(Person2 other) { names = other.names; address = new Address2(other.address); }