c# 使用泛型序列化

复制代码
static void Serialize<T>(T instance , string fileName)
{
    using(XmlWriter writer = new XmlWriter(filename , Encoding.UTF8))
    {
          XmlSerializer serializer = new  XmlSerializer(typeof(T));
          serializer.Serialize(writer , instance);
    }
}


Serialize<Order>(order , "order.xml");
复制代码

 

posted @   louiskoo  阅读(1964)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示