Clone:Xml序列化反序列克隆对象
public static T Clone<T>(T t)
{
T clone;
System.Xml.Linq.XDocument doc = new System.Xml.Linq.XDocument();
System.Xml.XmlWriter w = doc.CreateWriter();
System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(typeof(T));
s.Serialize(w, t);
w.Flush();
w.Close();
clone = (T)s.Deserialize(doc.CreateReader());
return clone;
}
上一篇:MySQL数据库密码忘记,不用怕![ 06-08 ]下一篇:DataReader 从数据库中检索只读、只进的数据流用法[ 06-10 ]
©Copyright2004 - 2009 www.bjaccp.com, All Rights Reserved
版权所有2004-2008 北大青鸟APTECH( 北京佳音旗舰 ) 授权培训中心
- 51.la

招生简章


