Useful extension methods for deep-cloning an object.
There are 3 extension methods available:
class Test { public string Value { get; set; } public Test Nested { get; set; } } var A = new Test { Value = "something", Nested = new Test { Value = "else" } }; var B = A.DeepClone(); // A and B are equal but not the same Assert.AreEqual(A.Value, B.Value); Assert.AreEqual(A.Nested.Value, B.Nested.Value); // Modifying B does not change A B.Nested.Value = "modified"; Assert.AreNotEqual(A.Nested.Value, B.Nested.Value);
Get GeorgeCloney at NuGet.org: https://www.nuget.org/packages/GeorgeCloney/