title: Get class by string value
body: <p>I have an abstract class with a few derived class</p>
  
  <pre><code>public abstract class MyObject
  {
      public string name { get; set; }
      public bool IsObject(string pattern);
      ...
  }
  
  public class MyObjectA : MyObject
  {
      public string name { get { return "MyObjectA"; } set; }
      public bool IsObject(string pattern) { ... }
      ...
  }
  
  public class MyObjectB: MyObject
  {
    public string name { get { return "MyObjectB"; } set; }
    public bool IsObject(string pattern) { ... }
    ...
  }
  </code></pre>
  
  <p>Now I want to have a function, which returns my the specific class (MyObjectA / MyObectB) based on a string. The problem is, that I have a lot of if/else-clauses to get that:</p>
  
  <pre><code>public MyObject Create(string pattern)
  {
      MyObjectA obj = new MyObjectA();
      if(obj.IsObject(pattern)
      {
          return obj;
      }
      else
      {
          MyObjectB objb = new MyObjectB();
          if(objb.IsObject(pattern);
              return objb;
          else
              ...
      }
  }
  </code></pre>
  
  <p>That looks just awful. What would be a better way to do this?</p>