Deep cloning objects in C#: how to properly copy a complex object with all nested references?
Hello everyone! I'm a beginner in C# and encountered a problem when copying objects. I have a `Person` class that contains reference fields, for example, `List`. When I try to make a copy using simple assignment (`var copy = original;`), changes in `copy` affect `original`. I understand that this is shallow copy, and I need deep clone.
I tried implementing `ICloneable`, but it creates a shallow copy. I tried manually copying each field, but it's terrible when there are many objects and they are nested.
Here's an example of my code:
```csharp
public class Address
{
public string Street { get; set; }
public string City { get; set; }
}
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
```