我有以下C#类属性:
private List<string> _accountTypes; [XmlArray(ElementName = "accountTypes")] public List<string> AccountTypes { get { return _accountTypes; } set { _accountTypes = value; } }
在类构造函数中初始化为:
_accountTypes = new List<string>( new string[] { "OHGEE","OHMY","GOLLY","GOLLYGEE" });
反序列化时,我得到了这个:
<accountTypes> <string>OHGEE</string> <string>OHMY</string> <string>GOLLY</string> <string>GOLLYGEE</string> </accountTypes>
如果我能得到这个,我应该喜欢它:
<accountTypes> <accountType>OHGEE</accountType> <accountType>OHMY</accountType> <accountType>GOLLY</accountType> <accountType>GOLLYGEE</accountType> </accountTypes>