mercredi 16 décembre 2015

How do i abstract TChild from Parent

I have 2 interfaces which use generic

my child interface looks like:

public interface ICell<TContent>
{
    TContent Content { get; }

    string Background { get; }
    string Foreground { get; }

}

and my Parent interface like:

public interface IRow<TRowHeader,TContent>
{
    TRowHeader RowHeader { get; }

    IList<ICell<TContent>> Zellen {get;}
}

when i create a class based on IRow i have to set the TContent which i want to avoid. So i would like to know how to abstract this generic away from my IRow?

in the end i want to be able to write

public class MyCell : ICell<string>
{
    public string Background { get; set; }
    public string Content { get; set; }
    public string Foreground { get; set; }
}

public class MyRow: IRow<string,MyCell>
{
    public string RowHeader { get; set; }
    public IList<MyCell> Zellen { get; set; }
}

Aucun commentaire:

Enregistrer un commentaire