title: How can we pass multiple objects from an XMLSerializer function
body: <p>How can we pass different objects of different classes by function overloading method?</p>
  
  <p>Example code:</p>
  
  <pre><code>static public void SerializeToXML(Movie movie)
  {
      XmlSerializer serializer = new XmlSerializer(typeof(Movie));
      TextWriter textWriter = new StreamWriter(@"C:\movie.xml");
      serializer.Serialize(textWriter, movie);
      textWriter.Close();
  }
  </code></pre>
  
  <p>when i use this code: </p>
  
  <pre><code>static public void SerializeToXML(FbTextView p, FbTextField q)
  {
      try
      {
          XmlSerializer textviewserilizer = new XmlSerializer(typeof(FbTextView));
          XmlSerializer textfieldserilizer = new XmlSerializer(typeof(FbTextField));
  
          TextWriter textWriter = new StreamWriter(@"D:\movie.xml");
          textviewserilizer.Serialize(textWriter, p);
          textfieldserilizer.Serialize(textWriter, q);
          textWriter.Close();
      }
      catch (Exception ex)
      {
          while (ex != null)
          {
              Trace.WriteLine(ex.Message);
              ex = ex.InnerException;
              MessageBox.Show(ex.Message);
          }
          throw;
      }
  }
  </code></pre>
  
  <p>its output xml display some result that is:</p>
  
  <pre><code>XML Parsing Error: junk after document element 
  Location: file:///D:/movie.xml
  Line Number 6, Column 14:&lt;/FbTextView&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt;
                           -------------^ 
  </code></pre>