title: c# generic method for mathematical operations
body: <p>I would like to create a generic method which performs basic mathematical operations. For eg. If a <strong>double</strong> is passed to the function, it will return <strong>double</strong>.</p>
  
  <pre><code>public static T Multiply&lt;T&gt; (T A, int B)
  {
     //some calculation here
     return (T) A * B; 
  }
  </code></pre>
  
  <p>This doesn't work for me. </p>
  
  <p><strong>EDIT</strong>: I get an error Operator '*' cannot be applied to operands of type 'T' and 'int'   </p>
  
  <p>However I am wondering if there are other ways to achieve what I am trying to?</p>
  
  <p>Thanks</p>