I have following class structure:
public class X
{
int foo = 0;
}
public class Y : X
{
int bar = 0;
}
public class Z: X
{
int foo2 = 0;
}
public abstract class A<T> where T : X
{
public abstract List<T> {get; set;}
}
public class B: A<Y>{}
public class C: A<Z>{}
Now I've the problem that I want to use these objects in a worker class like this:
public class Worker
{
B b = new B();
C c = new C();
public static void main()
{
doSome(b);
doSome(c);
}
private static void doSome(A<X> a)
{
}
}
Both derived types should be processed in this Method (it only needs the base properties). But I get the Error "Cannot convert from B to A < X >"
Is there any chance to achive something like this?