T
Torben Laursen
I have a class that is generic and can only be used with numerical types
like double or decimals
A example code is:
class<NumType>
{
public NumType Test(NumType Val)
{
NumType d = 0.0; //The problem is this line. This will not compile with the
error: Cannot convert type double to NumType
return Val + d;
}
}
Can anyone show me how to rewrite the code to it will compile?
For example is there a way of forcing the NumType to only be numerical
types?
Thanks Torben
like double or decimals
A example code is:
class<NumType>
{
public NumType Test(NumType Val)
{
NumType d = 0.0; //The problem is this line. This will not compile with the
error: Cannot convert type double to NumType
return Val + d;
}
}
Can anyone show me how to rewrite the code to it will compile?
For example is there a way of forcing the NumType to only be numerical
types?
Thanks Torben