title: XML Deserialization Array
body: <p>I have a class. I want to deserialize XML file into this class. </p>
  
  <pre><code>public partial class Form1 : Form
  {
      public string xmlFile;
  
      public Form1()
      {
          InitializeComponent();
          xmlFile = "Sample.xml";
      }
  
      [Serializable]
      public class Application
      {
          public string AppName;
          public string UpdateDetail;
      };
  
      [Serializable]
      public class Applications
      {
          [XmlElement]
          public Application[] Application;
      };
  
  
  
      [Serializable]
      public class Pmsp_Update
      {
          public string OldVersion;
          public string NewVersion;
          public Applications Applications;
      };
  
      private void btnRead_Click(object sender, EventArgs e)
      {
          XmlReader reader = XmlReader.Create(xmlFile);
          XmlSerializer ser = new XmlSerializer(typeof(Pmsp_Update));
          Pmsp_Update pu;
          using (reader = XmlReader.Create(xmlFile))
          {
              pu = (Pmsp_Update)ser.Deserialize(reader);
          }
      }
  }
  </code></pre>
  
  <p>And here is the XML:</p>
  
  <pre><code>&lt;Pmsp_Update&gt;
    &lt;OldVersion&gt;v4.0.0&lt;/OldVersion&gt;
    &lt;NewVersion&gt;v4.0.1&lt;/NewVersion&gt;
    &lt;Applications&gt;
      &lt;Application&gt;
        &lt;AppName&gt;SampleApp&lt;/AppName&gt;
        &lt;UpdateDetail&gt;sample&lt;/UpdateDetail&gt;
       &lt;/Application&gt;
    &lt;/Applications&gt;
  &lt;/Pmsp_Update&gt;
  </code></pre>
  
  <p>I want to ask about attributes. I only used <code>[Serializable]</code> attribute and I can get the class. I don't use any <code>[XmlElement]</code> attribute and this didn't cause any error except one.</p>
  
  <p>If I use like this I can populate the array but:</p>
  
  <pre><code>        [Serializable]
          public class Applications
          {
              [XmlElement]
              public Application[] Application;
          };
  </code></pre>
  
  <p>If I use like this I can't populate the array:</p>
  
  <pre><code>[Serializable]
  public class Applications
  {
      public Application[] Application;
  };
  </code></pre>
  
  <p>So, my question is this: I am not using <code>[XmlElement]</code> for fields and everything works well but I can't populate the array. Why couldn't I populate the array when I don't use <code>[XmlElement]</code> although I can populate the fields?</p>