I have an abstract class which specifies an abstract getter/setter property. Lets say it should return type "Tree", but in my derived classes I want it to return a more specific Tree type e.g. Redwood, Oak, etc, but they still inherit from Tree - this of course doesnt work because its too strongly typed. Is there a way round this?
Regards (Hope that makes sense BTW!!)
See example code below to see what I mean:
Regards (Hope that makes sense BTW!!)
See example code below to see what I mean:
Code:
//THIS IS THE BASE ABSTRACT CLASS
public abstract class Forest
{
public abstract Tree PropertyTree
{
get;
set;
}
}
//THIS IS THE DERIVED ACTUAL CLASS
public class MyForest: Forest
{
private OakTree _oakTree; //OAKTREE INHERITS FROM TREE CLASS!!! V.IMPORTANT
public override OakTree PropertyTree
{
get { return _oakTree; }
set { _oakTree = value; }
}
}