I have this code for example
public class BaseClass
{}
public class DerivedClass1 : BaseClass
{}
public class DerivedClass2 : BaseClass
{ }
public class DerivedClass3 : BaseClass
{ }
public class GenericBaseClass<T> where T : BaseClass
{
public List<T> collection { get; set; }
}
Now I'd like to create a new class which would inherit from GenericBaseClass<T>
and have somehow a collection List in this class.
Is this even possible this way ?
Because List<BaseClass> = new List<DerivedCLass3>();
isn't valid.
Or the only way to achieve this is to remove the collection
property from the GenericBaseClass
and add a collection List directly in the derived class.
I hope I expressed myself understandable as English isn't my first language :-)