title: How to dynamically cast an object of type string to an object of type T
body: <p>I have this XML document</p>
  
  <pre><code>&lt;AdditionalParameters&gt;
  &lt;PublishToPdf Type ="System.Boolean"&gt;False&lt;/PublishToPdf&gt;
  &lt;/AdditionalParameters&gt;
  </code></pre>
  
  <p>in my code and I'm trying to build an array of arguments containing the <code>&lt;PublishToPdf&gt;</code> node.</p>
  
  <pre><code>object test = (object) ((typeof(publishNode.Attributes["Type"].value)) publishNode.InnerText);
  </code></pre>
  
  <p>This breaks at compile time of course. I can't figure out how to cast the <code>publishNode.InnerText('false')</code> to a runtime defined object of type specified in the XML file and store it in an object (which will conserve the type).</p>