C# inheritance of fields
- by Emil D
This is probably a silly question, but here it goes.Imagine you have the following classes:
public class C
{
}
public class D : C
{
//A subclass of C
}
public class A
{
C argument;
}
Now, I want to have a class B, that inherits from A.This class would obviously inherit the "argument" field, but I wish to force the "argument" field in B to be of type D, rather than C.Since D inherits from C this shouldn't create any problems.
So, how would achieve this in c# ?