title: Can I serialize a C# Type object?
body: <p>I'm trying to serialize a Type object in the following way:</p>
  
  <pre><code>Type myType = typeof (StringBuilder);
  var serializer = new XmlSerializer(typeof(Type));
  TextWriter writer = new StringWriter();
  serializer.Serialize(writer, myType);
  </code></pre>
  
  <p>When I do this, the call to Serialize throws the following exception:  </p>
  
  <blockquote>
    <p>"The type System.Text.StringBuilder was not expected. Use the
    XmlInclude or SoapInclude attribute to specify types that are not
    known statically."</p>
  </blockquote>
  
  <p>Is there a way for me to serialize the <code>Type</code> object?  Note that I am not trying to serialize the <code>StringBuilder</code> itself, but the <code>Type</code> object containing the metadata about the <code>StringBuilder</code> class.</p>