I'm new to C# (I am a Java developer) and have a question about generics. I have a generic class with nested classes:
public class FlowChartBuilder<TEntity, TLink>
where TEntity : FlowChartBuilder<TEntity, TLink>.Entity
where TLink : FlowChartBuilder<TEntity, TLink>.Link
{
public abstract class Link { }
public abstract class Entity { }
}
The next I try to extends these classes:
public class ChartEntity<T>: FlowChartBuilder<ChartEntity<T>, ChartLink>.Entity
{
}
public class ChartEntity<T>: FlowChartBuilder<ChartEntity<T>, ChartLink<ChartEntity<T>>>.Entity
{
}
But I get an error:
"TEntity" type can't be used like a parameter of "TEntity" type in the universal type or method "FlowChartBuilder". There isn't a transformation-packaging or a transformation of a type parameter from the "TEntity" to the "PM.Utils.Diagram.FlowChartBuilder>.Entity".
How to write it correct?