public class Manager
{
List<GenericBase<IDisposeable>> list;
public void Add(GenericBase<IDisposable> obj)
{
list.add(obj);
}
}
public class GenericBase<T> where T : IDisposable
{
}
public class Resource : IDisposable
{
}
public class Inherited : GenericBase<Resource>
{
}
So what if I want to add an Inherited object to the list inside manager? I would think that the conversion to a GenericBase<IDisposeable> would be trivial considering that Resource inherits from IDisposeable and Inherited inherits from GenericBase. However, I get an error saying this conversion is not possible. Now I know that I can write a conversion operator inside Inherited to fix this but I feel like it is annoying and redundant to do this every time I create a new class inheriting from the GenericBase class. Is there anyway to get around this?






