C#XmlSerializer 序列化/反序列化

比如,随便写个类 
    public class TestClass 
    { 
        private int a; 
        private string b; 

        public int A 
        { 
            get { return a; } 
            set { a = value; } 
        } 

        public string B 
        { 
            get { return b; } 
            set { b = value; } 
        } 
    } 

序列化它: 
            TestClass test = new TestClass(); 
            test.A = 100; 
            test.B = "abc"; 
            XmlSerializer xs = new XmlSerializer(test.GetType()); 

            XmlWriter xw = new XmlTextWriter("c:\\test.xml", Encoding.UTF8); 
            xs.Serialize(xw, test);
原文地址:https://www.cnblogs.com/iplaycode/p/3404860.html