XSD:使用Visual Studio xsd.exe不生成Array 而不是List

我使用xsd.exe工具从xsd文件生成类。 xsd文件:

                                    

输出是:

 ///  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)] public partial class BAXML { private string counterpartyOrgNrField; private BAXMLLimit[] limitField; ///  [System.Xml.Serialization.XmlElementAttribute("Limit")] public BAXMLLimit[] Limit { get { return this.limitField; } set { this.limitField = value; } }} ///  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)] public partial class BAXMLLimit { private string limitTypeField; private int amountField; ///  public string LimitType { get { return this.limitTypeField; } set { this.limitTypeField = value; }} ///  public int Amount { get { return this.amountField; } set { this.amountField = value; } }} 

代替:

 private BAXMLLimit[] limitField; 

我希望它是

 List limitField 

xsd todo有这种方式吗? 或者其他一些方式? 谢谢!

尝试使用xsd2code 。 这比xsd.exe更好。 您还可以通过设置CollectionObjectType属性将选项指定为列表或数组。