public T Clone<T>(T RealObject)
{
using (System.IO.Stream objectStream = new System.IO.MemoryStream())
{
System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(objectStream, RealObject);
objectStream.Seek(0, System.IO.SeekOrigin.Begin);
return (T)formatter.Deserialize(objectStream);
}
}
原文地址:http://www.cnblogs.com/shijun/p/3807822.html