CSharp examples for System:Object
Deep Clone generic Type
using System.Runtime.Serialization.Formatters.Binary; using System.IO;//from w ww. j a va2s. co m public class Main{ public static T Clone<T>(T instance) { var serializer = new BinaryFormatter(); var ms = new MemoryStream(); serializer.Serialize(ms, instance); ms.Position = 0; return (T)serializer.Deserialize(ms); } }