I am newbie in C#. I need to create a generic class. There should be one constraint also : "client can implement by Int or Float class". Contains a 'totalNums' method which will return total.
Generic Class
public class clsPrint<T>
{
public T totalNums(T num1, T num2)
{
T Total = num1 + num2;
return Total;
}
}
Compile time error on "Num1 + Num2" : Operator '+' cannot be applied to operands of type 'T' and 'T'.
Why I am getting this error and what will be the solution?