标签:epc bsp color 反序列化 bin binary orm nbsp des
以下都是有缺陷的。
1 private static T BinDeepCopy<T>(T t) 2 { 3 using(var ms = new MemoryStream()) { 4 var bf = new BinaryFormatter(); 5 bf.Serialize(ms,t); 6 ms.Position = 0; 7 return (T)bf.Deserialize(ms); 8 } 9 } 10 11 private static T DomDeepCopy<T>(T t) 12 { 13 using(var ms = new MemoryStream()) { 14 XmlSerializer xml = new XmlSerializer(typeof(T)); 15 xml.Serialize(ms,t); 16 ms.Position = 0; 17 return (T)xml.Deserialize(ms); 18 } 19 } 20 21 private static T SoapDeepCopy<T>(T t) 22 { 23 using(var ms = new MemoryStream()) { 24 var soap = new SoapFormatter(); 25 soap.Serialize(ms,t); 26 ms.Position = 0; 27 return (T)soap.Deserialize(ms); 28 } 29 }
标签:epc bsp color 反序列化 bin binary orm nbsp des
原文地址:https://www.cnblogs.com/Lite/p/9076517.html