title: Serialize multiple objects
body: <p>My serialization code is like this..</p>
  
  <pre><code>public class slab
  {
      public int lowerlimit {get; set;}
      public int upperlimit { get; set; }
      public int percentage { get; set; }
  
  }
  
  public class Details
  {
      static void Main(string[] args)
      {
          slab s= new slab();
          s.lowerlimit = 0;
          s.upperlimit = 200000;
          s.percentage = 0;
          XmlSerializer serializer = new XmlSerializer(s.GetType());
          StreamWriter writer = new StreamWriter(@"filepath");
          serializer.Serialize(writer.BaseStream, s);
      }
  }
  </code></pre>
  
  <p>it's working fine and I am getting output file as:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;slab xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;lowerlimit&gt;0&lt;/lowerlimit&gt;
      &lt;upperlimit&gt;200000&lt;/upperlimit&gt;
      &lt;percentage&gt;0&lt;/percentage&gt;
  &lt;/slab&gt;
  </code></pre>
  
  <p>But how can I serialize more than one objects? I would like to get an output file as </p>
  
  <pre><code>&lt;slabs&gt;
      &lt;slab&gt;
          &lt;lowerlimit&gt;0&lt;/lowerlimit&gt;
          &lt;upperlimit&gt;200000&lt;/upperlimit&gt;
          &lt;percentage&gt;0&lt;/percentage&gt;
      &lt;/slab&gt;
      &lt;slab&gt;
          &lt;lowerlimit&gt;200000&lt;/lowerlimit&gt;
          &lt;upperlimit&gt;500000&lt;/upperlimit&gt;
          &lt;percentage&gt;10&lt;/percentage&gt;
      &lt;/slab&gt;
      &lt;slab&gt;
          &lt;lowerlimit&gt;500000&lt;/lowerlimit&gt;
          &lt;upperlimit&gt;1000000&lt;/upperlimit&gt;
          &lt;percentage&gt;20&lt;/percentage&gt;
      &lt;/slab&gt;
      &lt;slab&gt;
          &lt;lowerlimit&gt;1000000&lt;/lowerlimit&gt;
          &lt;upperlimit&gt;0&lt;/upperlimit&gt;
          &lt;percentage&gt;30&lt;/percentage&gt;
      &lt;/slab&gt;
  &lt;/slabs&gt;
  </code></pre>