I have a base class that inherits List<> which has multiple classes derived from it.
I want to create a method that can add items to any class that has inherited from this base class, is this possible ?
pseudo code:
public class BaseList<T> : List<T> where T: baseItem
{
}
public BaseList<T> AddItems<T>(int someArg) where T: new(), baseItem
{
BaseList<T> temp = new BaseList<T>();
temp.add(new T());
temp.add(new T());
return temp;
}
public class MyDerived: BaseList<SomeClass>
{
}
Then to call this code:
MyDerived temp = (MyDerived)AddItems();
is something like this possible ? I can't figure out the correct syntax