title: C# xml serialization remove jagged array element name
body: <p>I have the below classes:</p>
  
  <pre><code>public class MainRequest
  {
      private Request _dataField;
  
      [XmlElementAttribute("Parameters")]
      public Request Parameters
      {
          get
          {
              return _dataField;
          }
          set
          {
              _dataField = value;
          }
      }
  }
  
  
  public class Request
  {
      private RequestSize _requestSize;
  
      private Field[][] _field;
  
      [XmlElementAttribute(IsNullable = true)]
      public RequestSize RequestSize
      {
          get
          {
              return _requestSize;
          }
          set
          {
              _requestSize = value;
          }
      }
  
      [XmlArrayItem("BatchEntry")]
      [XmlArrayItemAttribute("ParameterEntry", IsNullable = false, NestingLevel = 1)]
      public Field[][] Batch
      {
          get
          {
              return _field;
          }
          set
          {
              _field = value;
          }
      }
  }
  
  public class RequestSize
  {
      private string _count;
  
      private string _value;
  
      [XmlAttributeAttribute]
      public string Count
      {
          get
          {
              return _count;
          }
          set
          {
              _count = value;
          }
      }
  
      [XmlTextAttribute]
      public string Value
      {
          get
          {
              return _value;
          }
          set
          {
              _value = value;
          }
      }
  }
  
  
  public class Field
  {
  
      private string _fieldName;
  
      private string _fieldValue;
  
      [XmlAttributeAttribute(AttributeName = "name")]
      public string Name
      {
          get
          {
              return _fieldName;
          }
          set
          {
              _fieldName = value;
          }
      }
  
      [XmlTextAttribute]
      public string Value
      {
          get
          {
              return _fieldValue;
          }
          set
          {
              _fieldValue = value;
          }
      }
  }
  </code></pre>
  
  <p>When they are serialized I get:</p>
  
  <pre><code>&lt;Parameters&gt;
    &lt;RequestSize Count="1"&gt;2&lt;/RequestSize&gt;
    &lt;Batch&gt;
      &lt;BatchEntry&gt;
        &lt;ParameterEntry name="AAA"&gt;111&lt;/ParameterEntry&gt;
        &lt;ParameterEntry name="BBB"&gt;222&lt;/ParameterEntry&gt;
        &lt;ParameterEntry name="CCC"&gt;333&lt;/ParameterEntry&gt;
      &lt;/BatchEntry&gt;
    &lt;/Batch&gt;
  &lt;/Parameters&gt;
  </code></pre>
  
  <p>I am trying to get rid of the <strong>Batch</strong> element.  What I want the xml to look like is:</p>
  
  <pre><code>&lt;Parameters&gt;
    &lt;RequestSize Count="1"&gt;2&lt;/RequestSize&gt;
    &lt;BatchEntry&gt;
      &lt;ParameterEntry name="AAA"&gt;111&lt;/ParameterEntry&gt;
      &lt;ParameterEntry name="BBB"&gt;222&lt;/ParameterEntry&gt;
      &lt;ParameterEntry name="CCC"&gt;333&lt;/ParameterEntry&gt;
    &lt;/BatchEntry&gt;
  &lt;/Parameters&gt;
  </code></pre>
  
  <p>I tried using the XmlElement attribute on the Field[][] but I get an error when I do that:</p>
  
  <pre><code>[XmlElement("Batch")]
  public Field[][] Batch
  {
      get
      {
          return _field;
      }
      set
      {
          _field = value;
      }
  }
  
  
  
  Error   97  Cannot convert type 'Field[][]' to 'Field[]'
  </code></pre>
  
  <p>Is there a way I can serialize the array elements without that top level element name?</p>