title: Arithmetic operator overloading for a generic class in C#
body: <p>Given a generic class definition like </p>
  
  <pre><code>public class ConstrainedNumber&lt;T&gt; :
      IEquatable&lt;ConstrainedNumber&lt;T&gt;&gt;,
      IEquatable&lt;T&gt;,
      IComparable&lt;ConstrainedNumber&lt;T&gt;&gt;,
      IComparable&lt;T&gt;,
      IComparable where T:struct, IComparable, IComparable&lt;T&gt;, IEquatable&lt;T&gt;
  </code></pre>
  
  <p>How can I define arithmetic operators for it?</p>
  
  <p>The following does not compile, because the '+' operator cannot be applied to types 'T' and 'T':</p>
  
  <pre><code>public static T operator +( ConstrainedNumber&lt;T&gt; x, ConstrainedNumber&lt;T&gt; y)
  {
      return x._value + y._value;
  }
  </code></pre>
  
  <p>The generic type 'T' is constrained with the 'where' keyword as you can see, but I need a constraint for number types that have arithmetic operators (IArithmetic?).</p>
  
  <p>'T' will be a primitive number type such as int, float, etc.  Is there a 'where' constraint for such types?</p>