C#学习教程:XmlSerializer不会序列化我类中的所有内容[可序列化]publicclassProductCollection:List{publicboolflag{get;放;}publicdoubleA{get;放;}publicdoubleB{get;放;}公共双C{得到;放;}}...//保存此类的方法privatevoidSaveProductCollection(){//将案例导出为XML...XmlSerializerxml=newXmlSerializer(typeof(ProductCollection));StreamWritersw=newStreamWriter("output.xml");xml.Serialize(sw,theCollection);sw.Close();}[可序列化]publicclassProductCollection:List{publicboolflag{get;放;}publicdoubleA{get;放;}publicdoubleB{get;放;}公共双C{得到;放;}}...//保存此类的方法privatevoidSaveProductCollection(){//将案例导出为XML...XmlSerializerxml=newXmlSerializer(typeof(ProductCollection));StreamWritersw=newStreamWriter("output.xml");xml.Serialize(sw,theCollection);sw.Close();}[可序列化]publicclassProductCollection:List{publicboolflag{get;尝试将XmlAttribute添加到属性中,以便将它们序列化为属性。就好比:以上是C#学习教程:XmlSerializer不会序列化我班的所有内容。如果对大家有用,需要进一步了解C#学习教程,希望大家多多关注——[XmlAttribute("flag")]publicboolflag{get;放;}本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
