title: Better Solution to find all classes which inherit from a baseclass (and interface) and return a list not List<System.Type> but List<Interface>
body: <p>Maybe my brain is not working properly and i cant see the forest because of the trees ... </p>
  
  <p>Currently I have a class called <code>CheckManager</code> which searches the current assembly for a certain type called <code>UserControlBaseCheck</code> which is declared in a separate library.  (this works fine)</p>
  
  <p>I do have a variable <em>AllChecks</em> of type <code>SortedDictionary&lt;IBaseCheck, UserControlBaseCheck&gt;</code> (and a custom <code>IComparer</code> class which know's how to sort <code>IBaseCheck</code>).</p>
  
  <p>This variable <em>AllChecks</em> is used to populate a <code>Stack</code>. The stack is then worked through by a User, once it is depleted, it get's filled again with new instances of all classes inside the <code>AllChecks</code> variable. And the whole game starts again.</p>
  
  <p>Currently i solved it this way:</p>
  
  <pre><code>//declaration of my container with all checks
  private static SortedDictionary&lt;IBaseCheck, UserControlBaseCheck&gt; AllChecks =
          new SortedDictionary&lt;IBaseCheck, UserControlBaseCheck&gt;(new Comparer());
  
  // this is how i call the method to find all classes which inherit from the type
  FindDerivedTypes(Assembly.GetExecutingAssembly(), typeof(UserControlBaseCheck));
  
  //this is the definition... it seems to me bit odd that I have to use the Activator 
  //and create an instance and cast it to the interface just to do 
  //what i want to do... 
  //is there any other / easier / better way of doing so?
  public static IList&lt;IBaseCheck&gt; FindDerivedTypes(Assembly assembly,Type baseType)
  {
        //FYI: until the '.Select' I get a list of type List&lt;System.Type&gt;
        List&lt;IBaseCheck&gt; o = assembly.GetTypes()
          .Where(t =&gt; t != baseType &amp;&amp; baseType.IsAssignableFrom(t))
          .Select(type =&gt; Activator.CreateInstance(type) as IBaseCheck)
          .ToList();
  
        return o;
  }
  </code></pre>
  
  <p>i find it odd that I have to create first an instance of the type  just to use/convert it to an interface. Why can't i just do:  <code>.Select(x=&gt; x as IBaseCheck)</code> I mean i have already a list with object of type <code>List&lt;System.Type&gt;</code> and it seems to me bit overkill what i am doing just to get my list of type  <code>IBaseCheck</code> (<code>List&lt;IBaseCheck&gt;</code>)</p>