Hi i have this
pulic class BackGroundClass<T,X> : BaseClass where T : AnotherBaseClass where X : AnotherBaseClass { } public class MyClassA : BackGroundClass<FooA, BarA>// FooA and BarA both inherit from AnotherBaseClass<T,X> { } public class MyClassB : BackGroundClass<FooB, BarB>// FooB and BarB both inherit from AnotherBaseClass<T,X> { } public class MyClassC : BackGroundClass<FooC, BarC>// FooC and BarC both inherit from AnotherBaseClass<T,X> { }
now what i want to is is have one list which contains multiple instances of MyClassA, MyClassB and MyClassC
i would be happy with
var myList = new List<BackGroundClass<AnotherBaseClass, AnotherBaseClass>>()
but if I do
var myClassC = new MyClassC ();
myList.Add(myClassC);
it doesn't work and myList is null
doing
someMethod( myClassC as BackGroundClass<AnotherBaseClass, AnotherBaseClass>)
also doesn't work
any suggestions would be appriciated.