title: XML serialization, encoding
body: <pre><code>using System;
  
  public class clsPerson
  {
    public  string FirstName;
    public  string MI;
    public  string LastName;
  }
  
  class class1
  { 
     static void Main(string[] args)
     {
        clsPerson p=new clsPerson();
        p.FirstName = "Jeff";
        p.MI = "A";
        p.LastName = "Price";
        System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType());
        x.Serialize(Console.Out, p);
        Console.WriteLine();
        Console.ReadLine();
     }
  } 
  </code></pre>
  
  <p>taken from <a href="http://support.microsoft.com/kb/815813" rel="noreferrer">http://support.microsoft.com/kb/815813</a></p>
  
  <p>1) </p>
  
  <pre><code>System.Xml.Serialization.XmlSerializer x = new System.Xml.Serialization.XmlSerializer(p.GetType());
  </code></pre>
  
  <p>What does this line do? what is GetType()?</p>
  
  <p>2) how do I get the encoding to </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt; clsPerson xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="IBM437"?&gt;
   &lt;clsPerson xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3
   .org/2001/XMLSchema"&gt;
  </code></pre>
  
  <p>or not include the encoding type at all?</p>