title: xsd.exe generated c# with multiple elements in an array
body: <p>I have a set of XML schema files provided to me. I cannot changed the XML as these will be updated on occasion. I am using xsd.exe to convert the schema files to generated c# code. I cannot use any third party tools. Part of one of the XML schema files appears as such:</p>
  
  <pre><code>&lt;xs:complexType name="LocationType"&gt;
    &lt;xs:choice minOccurs="1" maxOccurs="1"&gt;
      &lt;xs:element name="LocNum" minOccurs="1" maxOccurs="1" type="xs:string" /&gt;
      &lt;xs:sequence&gt;
        &lt;xs:element name="Name" minOccurs="0" maxOccurs="1" type="xs:string" /&gt;
        &lt;xs:element name="Address" minOccurs="0" maxOccurs="1" type="xs:string" /&gt;
        &lt;xs:element name="City" minOccurs="1" maxOccurs="1" type="xs:string" /&gt;
        &lt;xs:element name="State" minOccurs="0" maxOccurs="1"&gt;
      &lt;/xs:sequence&gt;
    &lt;/xs:choice&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p>When converted to c#, I get a result such as this:</p>
  
  <pre><code>[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://abcxyz.com")]
  public partial class LocationType
  {
  
      private object[] itemsField;
  
      private ItemsChoiceType[] itemsElementNameField;
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute("Address", typeof(string), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
      [System.Xml.Serialization.XmlElementAttribute("City", typeof(string), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
      [System.Xml.Serialization.XmlElementAttribute("LocNum", typeof(string), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
      [System.Xml.Serialization.XmlElementAttribute("Longitude", typeof(decimal), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
      [System.Xml.Serialization.XmlElementAttribute("State", typeof(LocationTypeState), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
      [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
      public object[] Items
      {
          get { return this.itemsField; }
          set { this.itemsField = value; }
      }
  
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlElementAttribute("ItemsElementName")]
      [System.Xml.Serialization.XmlIgnoreAttribute()]
      public ItemsChoiceType[] ItemsElementName
      {
          get { return this.itemsElementNameField; }
          set { this.itemsElementNameField = value; }
      }
  }
  </code></pre>
  
  <p>Since these all get generated to partial classes, I am free to add additional code. I need to be able to read/set the individual properties, such as Name, Address, City, etc.</p>
  
  <p>I need to be able to serialize these objects to match the schema.</p>
  
  <p>Is there a way in c# to create a public property that will read or set the value in the Items array at the proper sequence, etc.? ie:</p>
  
  <pre><code>public partial class LocationType
  {
      public string Address
      {
          get
          {
              // code here to return the correct Items[] element
          }
          set
          {
              // code here to set the correct Items[] element
          }
      }
  }
  </code></pre>