Scenario is
public interface IRow
{
int Id { get; set; }
string Name { get; set; }
}
public class ARow : IRow
{ ... }
public class BRow : IRow
{ ... }
public class RowCollection<T> : Collection<T> where T : IRow
{ }
public interface ITable<T> where T : IRow
{
RowCollection<T> DataRows { get; }
int Id { get; set; }
string Name { get; set; }
}
public class ATable : ITable<ARow>
{
public RowCollection<ARow> DataRows
{
get;
set;
}
}
public class BTable : ITable<BRow>
{
public RowCollection<BRow> DataRows
{
get;
set;
}
}
When i do something like this
List<ITable<IRow>> lt = new List<ITable<IRow>>();
ITable<IRow> ads = new ATable();
I get error, i know its something to do with covariance and contravariance if someone can help me overcome this error will be much appreciated.
For sure i need to learn more on this topic but expecting a quick help on fixing this issue/scenario first.
Regards, San