title: How to find all direct subclasses of a class with .NET Reflection
body: <p>Consider the following classes hierarchy: base class A, classes B and C inherited from A and class D inherited from B.</p>
  
  <pre><code>public class A     {...}
  public class B : A {...}
  public class C : A {...}
  public class D : B {...}
  </code></pre>
  
  <p>I can use following code to find all subclasses of A including D:</p>
  
  <pre><code>var baseType = typeof(A);
  var assembly = typeof(A).Assembly;
  var types = assembly.GetTypes().Where(t =&gt; t.IsSubclassOf(baseType));
  </code></pre>
  
  <p>But I need to find only direct subclasses of A (B and C in example) and exclude all classes not directly inherited from A (such as D).
  Any idea how to do that? </p>