title: Create generic class with internal constructor
body: <p>Is it possible to construct an object with its internal constructor within a generic method?</p>
  
  <pre><code>public abstract class FooBase { }
  
  public class Foo : FooBase {
     internal Foo() { }
  }
  
  public static class FooFactory {
      public static TFooResult CreateFoo&lt;TFooResult&gt;()
      where TFooResult : FooBase, new() {
          return new TFooResult();
      }
  }
  </code></pre>
  
  <p><code>FooFactory</code> resides in the same assembly as <code>Foo</code>. Classes call the factory method like this:</p>
  
  <pre><code>var foo = FooFactory.CreateFoo&lt;Foo&gt;();
  </code></pre>
  
  <p>They get the compile-time error:</p>
  
  <blockquote>
    <p>'Foo' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'TFooType' in the generic type or method 'FooFactory.CreateFoo()'</p>
  </blockquote>
  
  <p>Is there any way to get around this?</p>
  
  <p>I also tried:</p>
  
  <pre><code>Activator.CreateInstance&lt;TFooResult&gt;(); 
  </code></pre>
  
  <p>This raises the same error at runtime.</p>