interface TerminationCondition
{
static bool IsSatisfied(some parameters);
}
Let's say some classes A and B implement this interface.
Some other class C has a generic type:
class C<termCondition> where termCondition : TerminationCondition
I need to call IsSatisfied from C accordingly, whether I have passed A or B for the generic type. For some reason it is not possible termCondition.IsSatisfied().
To summarize, the question is How do I call static method for a generic type in a class?
This is not possible.
In fact, you can't have static methods in an interface at all.
Since termCondition is required to be of type TerminationCondition, you could simple have IsSatisfied be an instance method of the classes that implement that interface. There's no need to have that method be static at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With