title: Dynamic class initialization in .NET
body: <p>Let's say I have base class <code>FooParent</code>, and it has a numerous amount of <code>FooChildren</code>. At runtime I must create an instance of one of the <code>FooChildren</code>. How would I do this? I realize I could create a huge map (and use delegates) or a huge <code>switch/case</code> statement, but that just seems a bit sloppy. In something like PHP, I can easily create a class dynamically like this:</p>
  
  <pre><code>$className="FooClass";
  $myNewFooClass=new $className; //makes a new instance of FooClass
  </code></pre>
  
  <p>(you can also do this using reflection).</p>
  
  <p>Does .NET have anything like this? Is reflection an option, and does it have any performance penalties? If not, what other options do I have?</p>
  
  <p>The type of class will be determined by a JSON request. The variable could be anything I want..it could be an integer if I wanted to do an enum, or it could be the full class name. I haven't created it yet so I'm undecided.</p>