Deep vs. Shallow Copying
Suppose we define a class Person as
public class Person
{
public readonly string Name;
public readonly Address Address;
public Person(string name, Address address) { ... }
}
with the Address defined as
public class Address
{
public readonly string StreetName;
public int HouseNumber;
public Address(string streetName, int houseNumber) { ... }
}
Suppose John Smith and Jane Smith are neighbors. It should be possible to construct John, then just copy him and change the house number, right? Well, using the assignment operator (=) certainly won’t help: ...