c# XML序列化

2021-07-09 01:05

阅读:513

标签:begin   serialize   oid   origin   col   ret   序列化   HERE   lse   

 public static T Deserialize(S stream) where S : Stream where T : class, new()
        {
            using (stream)
            {
                XmlSerializer xmlSearializer = new XmlSerializer(typeof(T));
                //    fileStream.Position = 0;
                // fileStream.Seek(0, SeekOrigin.Begin);
                return (T)xmlSearializer.Deserialize(stream);
            }

        }

        public static void Serialize(T obj, S stream) where S : Stream where T : class, new()
        {
            using (stream)
            {
                XmlSerializer xmlFormat = new XmlSerializer(typeof(T));
                xmlFormat.Serialize(stream, obj);
            }
        }

 

c# XML序列化

标签:begin   serialize   oid   origin   col   ret   序列化   HERE   lse   

原文地址:https://www.cnblogs.com/yuanzijian-ruiec/p/9720885.html


评论


亲,登录后才可以留言!