0

I have a class called TabularSectionManager and each Manager linked to TabularBusinessObject.

public abstract class TabularSectionManager<T1> : where T1 : TabularBusinessObject
{
    public TabularSectionManager()
    {
    }

    public T1 LinkedTabularBusinessObject { get; set; } 
}

public class PhoneManager : TabularSectionManager<PhoneBo>
{
    public PhoneManager()
    {

    }
}

public class PhoneBo : TabularBusinessObject
{
    public PhoneBo()
    {

    }
}

Finally, there is another class stores collection of TabularBusinessObjectManager List.

Compiler is complaining here regarding conversion:

List<TabularSectionManager<TabularBusinessObject>> TabularSections { get; set; }

TabularSections.Add(new PhoneManager());

Error CS1503 Argument 1: cannot convert from "PhoneManager" to "TabularSectionManager< TabularBusinessObject >".

Could you pls advice on that?

Thanks.

Tim
  • 459
  • 1
  • 4
  • 20
  • 2
    _"Compiler is complaining here regarding conversion:"_ - is the compiler message just "there's a problem with this line of code?" Odd. Usually it's more specific than that. – ProgrammingLlama Dec 07 '18 at 05:36
  • 1
    In other words, what is the complaint made by the compiler? – bit Dec 07 '18 at 05:37
  • 1
    `PhoneManager` isn't a derived class of `TabularSectionManager`, it's a derived class of `TabularSectionManager`. To understand why, read [this](https://stackoverflow.com/a/1817341/3181933) – ProgrammingLlama Dec 07 '18 at 05:42
  • [This is also good](https://stackoverflow.com/a/2033921/3181933) – ProgrammingLlama Dec 07 '18 at 05:49
  • Dear All. I understand the limitation. However, the link you provided are mostly related conversion from List to List. In my case, I am trying adding new instance of DerivedClass to List. Could you pls help? – Tim Dec 07 '18 at 07:09

0 Answers0