using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.Serialization.Formatters.Binary; using System.Text; using System.Threading.Tasks; namespace Common { [Serializable] public class DeepCopyHelper<T> : ICloneable { public T data { get; set; } public DeepCopyHelper(T t) { this.data = t; } public object Clone() { var bf = new BinaryFormatter(); var ms = new MemoryStream(); bf.Serialize(ms, this); ms.Position = 0; return bf.Deserialize(ms); } } }