<t>Whereas one approach is to implement the ICloneable interface (described here, so I won't regurgitate), here's a nice deep clone object copier I found on The Code Project a while ago and incorporated it into our code.<br/>
As mentioned elsewhere, it requires your objects to be serializable.<br/>
<br/>
using System;<br/>
using System.IO;<br/>
using System.Runtime.Serialization;<br/>
using System.Runtime.Serialization.Formatters.Binary;<br/>
<br/>
/// <br/>
/// Reference Article http://www.codeproject.com/KB/tips/SerializedObjectCloner.aspx<br/>
/// Provides a method for performing a deep copy of an object.<br/>
/// Binary Serialization is used to perform the copy.<br/>
/// <br/>
public static class ObjectCopier<br/>
{<br/>
/// <br/>
/// Perform a deep copy of the object via serialization.<br/>
/// <br/>
/// The type of object being copied.<br/>
/// The object instance to copy.<br/>
/// A deep copy of the object.<br/>
public static T Clone(T source)<br/>
{<br/>
if (!typeof(T).IsSerializable)<br/>
{<br/>
throw new ArgumentException("The type must be serializable.", nameof(source));<br/>
}<br/>
<br/>
// Don't serialize a null object, simply return the default for that object<br/>
if (ReferenceEquals(source, null)) return default;<br/>
<br/>
using var stream = new MemoryStream();<br/>
IFormatter formatter = new BinaryFormatter();<br/>
formatter.Serialize(stream, source);<br/>
stream.Seek(0, SeekOrigin.Begin);<br/>
return (T)formatter.Deserialize(stream);<br/>
}<br/>
}<br/>
<br/>
```<br/>
<br/>
The idea is that it serializes your object and then deserializes it into a fresh object. The benefit is that you don't have to concern yourself about cloning everything when an object gets too comp<br/>
<br/>
*(Réponse tronquée)*</t>