I want to overload an operator in a class. I want the overload method to be generic. For example:
class Subtractable
{
public static Subtractable operator-<T>(Subtractable a, T b)
{
//Implementation
}
}
When I do this, I get the following message at the generic type parameter:
Syntax error, '(' expected
If I remove the generic type parameter, I get the following message at b
's type:
The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?)
Is there some way to achieve this? If so, how? If not, why?