title: Call object from string
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/223952/c-sharp-create-an-instance-of-a-class-from-a-string">c# create an instance of a class from a string</a>  </p>
  </blockquote>
  
  
  
  <p>Hopefully this is pretty straightforward.</p>
  
  <p>I'm looking to dynamically call an object based off a string representation of its name. Here is an example of what I'm looking to do:</p>
  
  <pre><code>public class Class1
  {
      public string Property1 { get; set; }
      public string Property2 { get; set; }
      public string Property3 { get; set; }
  }
  
  public class Class2
  {
      public string Property1 { get; set; }
      public string Property2 { get; set; }
      public string Property3 { get; set; }
  }
  </code></pre>
  
  <p>My goal is to call <code>Class2</code> from a string representation (the <code>GetClassFromString()</code> is obviously made up, but hopefully describes what I'm looking to do):</p>
  
  <pre><code>Object cls = Object.GetClassFromString("Class2");
  </code></pre>
  
  <p>Then <code>cls</code> would be an object from <code>Class2</code>.</p>