私はC#(私はJava開発者です)に新しく、genericsに関する質問があります。次の私がこれらのクラス拡張してみてくださいクラスを他のジェネリッククラスのネストからどのように拡張できますか?
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 { }
}
:
public class ChartEntity<T>: FlowChartBuilder<ChartEntity<T>, ChartLink>.Entity
{
}
public class ChartEntity<T>: FlowChartBuilder<ChartEntity<T>, ChartLink<ChartEntity<T>>>.Entity
{
}
をしかし、私はエラーを取得する:私は、ネストされたクラスとジェネリッククラスを持って
"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".
それが正しい書き方?
はこちら
チェックがクールになる –
申し訳ありませんが、私は気付きませんでした。私はすでにそれを翻訳しました。 –
私はこれがこのhttp://stackoverflow.com/questions/21566701/nested-class-that-inherits-from-its-generic-parent-classの複製であると思うかもしれません。それは、継承を包み込みで置き換えることを指示します。 –