自定义类序列化成xml,并获得xml内容

            

            using System.Xml.Serialization;
            //--序列化到XML

            MemoryStream s = new MemoryStream();
            XmlSerializer serializer = new XmlSerializer(sm.GetType());

    //将类sm序列化到s中
            serializer.Serialize(s, sm);
           //依次读取s里的内容
             string inputString = System.Text.Encoding.Default.GetString(s.ToArray());

    

posted @ 2010-10-27 18:10  我的食草堂  阅读(224)  评论(0编辑  收藏  举报