將對象序列化為xml我繼承了一個C#類。我已經(jīng)成功地“建造”了這個物體。但我需要將對象序列化為XML。有什么簡單的方法嗎?類似乎已經(jīng)設置為序列化,但我不確定如何獲得XML表示。我的類定義如下:[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")][System.SerializableAttribute()][System.Diagnostics.DebuggerStepThroughAttribute()][System.ComponentModel.DesignerCategoryAttribute("code")][System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://www.domain.com/test")][System.Xml.Serialization.XmlRootAttribute(Namespace = "http://www.domain.com/test", IsNullable = false)]public partial class MyObject{ ...}以下是我認為我能做的,但它不起作用:MyObject o = new MyObject();// Set o propertiesstring xml = o.ToString();如何獲得該對象的XML表示?
將對象序列化為xml
慕碼人2483693
2019-07-04 14:59:35