Hi,
I have a problem, I want to use a generic node interface like this:
interface Node<T>
{
int doStuff(T other);
}
I want to make sure that an implementation would always have to be like this:
class Waypoint : Node<Waypoint>
Therefore I declared my node interface like this:
interface Node<T> where T : Node<T>
However, C# seems to ignore it when I use it like this:
class Waypoint : Node<Waypoint>
class WrongClass : Node<Waypoint>
This should not work, since Waypoint is not of type WrongClass? The compiler does not mark it for an error and it does not produce any kind of runtime error when I use
int doStuff(Waypoint other)
in a WrongClass object.
Is there any way to acheive the desired restriction?
greetings
FreetimeCoder