I am working on a transportation problem and cannot leap this hurdle. I am unable to convert the derived class StopsVisited to its base class Stops. The base class Stops is a collection of Stop. The derived class StopsVisited is a collection of StopVisited.
The element StopVisited derives from Stop (definitions not shown).
I have a non-generics workaround where I simplly derive StopsVisited from Stops, but the generics afford me more felixibility. I've tried to reduce it to its simplest form.
Base
public abstract class Stops<T> where T : Stop
{
}
Derived
public class StopsVisited : Stops<StopVisited>
{
}
The problem:
Stops<Stop> stops = new StopsVisited();
Gives me a
Error 1 Cannot implicitly convert type 'StopsHeirarchy.StopsVisited' to 'StopsHeirarchy.Stops'
Any help is appreciated.