Hi,
I am trying to use Generics to create a general method which accepts a
number as a parameter (integer, decimal, ...) and then performs some
calculations.
Below is a simplified example:
private static T test(T somenumber)
{
return ( somenumber * 2);
}
The problem is that this does not compile because the operator * is not
allowed on type T.
How can I solve this without using reference types/objects to do the
calculation ?
I tried adding the :
where T: struct
but it did not help.
I know c# 2.0 operators can not be defined in an interface so I also am
not able to define a different WHERE clause accepting the operator *.
Is there anybody that can help me with this ?
Thanks VERY MUCH in advance,
Regards,
Serge