Tuesday, 1 October 2013

assign list of parent class reference with list of child class object does not work C#

assign list of parent class reference with list of child class object does
not work C#

I am new to C#. I have a parent class declared:
class PmdTable
{
}
and I have a child class
class PmdSdStageCfg : PmdTable
{
Now it complains if I do like:
List<OracleObject.PmdTable> instanceList = new List<PmdSdStageCfg>();
The error says"Cannot implicityly convert type
'System.Collections.Generic.List' to 'System.Collection.Generics.List'".
Since PmdTable is the parent class. Why this does not work?

No comments:

Post a Comment