title: Get a new object instance from a Type and access it as such at compile-time
body: <p>Now, before you all rush in to tell me that question has been answered elsewhere <a href="https://stackoverflow.com/questions/752/get-a-new-object-instance-from-a-type" title="here">here</a>, for example or <a href="https://stackoverflow.com/questions/5622519/how-to-create-an-instance-for-a-given-type">here</a>, let me say it's only been partially answered, at least as far as I can see. </p>
  
  <p>I have a variable of type <code>Type</code> and I want to create an instance of the type that <code>t</code> represents, so I call something like...</p>
  
  <pre><code>var inst = Activator.CreateInstance(t);
  </code></pre>
  
  <p>However, <code>inst</code> is on <code>object</code> and I want it to be of type <code>t</code>. None of the following are legal:</p>
  
  <pre><code>t inst = Activator.CreateInstance(t);
  var inst = (t)Activator.CreateInstance(t);
  var inst = Activator.CreateInstance(t) as t;
  </code></pre>
  
  <p>How do I do this? How do I get <code>inst</code> to be the type that I want at compile-time?</p>