title: Inheritance on a constrained generic type parameter
body: <p>I know it isn't possible to inherit from a generic type parameter, but it would be handy when implementing a common proxy for derivatives of an abstract type :-)</p>
  
  <p>Does anyone know why this isn't possible?</p>
  
  <p>Example C#:</p>
  
  <pre><code>abstract class Foo
  {
    public virtual void Bar()
    {
       // nop
    }
  }
  
  class FooProxy&lt;TFoo&gt; : TFoo
    where TFoo : Foo
  {
  
    public override void Bar()
    {
      // do some stuff before
      base.Bar();
      // do some stuff after
    }
  
  }
  </code></pre>
  
  <p>EDIT: Some more code to illustrate an example of how this could be used. Consider the following derivatives of Foo:</p>
  
  <pre><code>class FooX : Foo
  {
    public string X { get; set; }
    public override void Bar()
    {
      Console.WriteLine("Doing Bar X");
    }
  }
  
  class FooY : Foo
  {
    public string Y { get; set; }
    public override void Bar()
    {
      Console.WriteLine("Doing Bar Y");
    }
  }
  </code></pre>
  
  <p>And the calling code:</p>
  
  <pre><code>FooProxy&lt;FooX&gt; fooXProxy = new FooProxy&lt;FooX&gt;();
  fooXProxy.X = "test X";
  fooXProxy.Bar();
  
  FooProxy&lt;FooY&gt; fooYProxy = new FooProxy&lt;FooY&gt;();
  fooYProxy.Y = "test Y";
  fooYProxy.Bar();
  </code></pre>
  
  <p>The code in the FooProxy override of Bar() method will be reused when using FooX and FooY.</p>
  
  <p>EDIT: Revised as per Pete OHanlon's answer: made Bar() method virtual.</p>