I'm a bit confused why i can't return my interface type to my generic variable when it is restricted to that interface type.
Here is what i have setup for my generics:
public class Graph<T, T2>
where T : ISegment
where T2 : INode
In this class i have the following lines:
T2 currNode = GetCurrentNode();
T segment = GetSegment();
T2 otherNode = segment.OtherNode(currNode);
My segment interface ISegment
has the following definition for OtherNode(INode)
INode OtherNode(INode node);
Since I have put where T2 : INode
for my class how come it gives me an error that says:
Cannot convert INode to T2
shouldn't this implicitly convert since I restricted my generic T2
to the interface INode
?