title: C# Generic Operators
body: <p>I am trying to implement a generic operator like so:</p>
  
  <pre><code>class Foo
  {
     public static T operator +&lt;T&gt;(T a, T b) 
     {
         // Do something with a and b that makes sense for operator + here
     }
  }
  </code></pre>
  
  <p>Really what I'm trying to do is gracefully handle inheritance. With a standard operator + in Foo, where T is instead "Foo", if anyone is derived from Foo (say Bar inherits Foo), then a Bar + Bar operation will still return a Foo. I was hoping to solve this with a generic operator +, but I just get a syntax error for the above (at the &lt;) making me believe that such code is not legal.</p>
  
  <p>Is there a way to make a generic operator?</p>