title: Handling float and double types with same generic parameter
body: <p>Say I have:</p>
  
  <pre><code>public class Matrix&lt;T&gt;
  {
      T[][] values;
      ...
  }
  </code></pre>
  
  <p>I want to add a <code>+</code> operator that would handle int, long, float and double or any other type that the <code>+</code> operator for T is implemented.</p>
  
  <p>For example (this does not work but conveys what I want to do):</p>
  
  <pre><code>public class Matrix&lt;T&gt;
  {
      T[][] values;
      ...
      public static Matrix&lt;T&gt; operator +(Matrix&lt;T&gt; A, Matrix&lt;T&gt; B)
      {
          values = ...;
          for (int row = 0; row &lt; rowCount; ++row)
          {
              for (int col = 0; col &lt; colCount; ++col)
              {
                  values[row][col] = A.values[row][col] + B.values[row][col];
              }
          }
      }
  }
  </code></pre>
  
  <p>Ideally I would want a way to limit T to only types that have the <code>+</code> operator defined to get a compile time error but failing that a runtime exception would do.
  Also I would like to add implicit conversions then from <code>Matrix&lt;float&gt;</code> to <code>Matrix&lt;double&gt;</code> but these cannot be defined in the <code>Matrix&lt;T&gt;</code> class, anyway around this?
  I know T4 templates could be used to generate a matrix for each type, but then the types need to be specified before hand and I would like this to work for any types the operator is defined for.</p>