I have 2 classes:
abstract class Bar { }
class Foo<T> where T : Bar { }
and I want to to create a List of 'Foo's that can have different generic classes that are all inherited from 'Bar':
class NewBar : Bar { }
But I can not save the classes as Foo<Bar>
:
Foo<Bar> variable = new Foo<NewBar>();
So what have I done wrong and how would this be possible?