C# Array XML Serialization

后端 未结 1 1269
陌清茗
陌清茗 2020-12-09 15:17

I found a problem with the XML Serialization of C#. The output of the serializer is inconsistent between normal Win32 and WinCE (but surprisingly WinCE has the IMO correcter

相关标签:
1条回答
  • 2020-12-09 16:01

    Try [XmlArrayItem("c2")]

    [XmlRoot("c1")]
    public class Class1
    {
        [XmlArray("items")]
        [XmlArrayItem("c2")] 
        public Class2[] Items;
    }
    

    or [XmlType("c2")]

    [XmlType("c2")]
    public class Class2
    {
        [XmlAttribute("name")]
        public string Name;
    }
    
    0 讨论(0)
提交回复
热议问题