I'm probably doing this totally wrong..
public class BaseClass
{
public string result { get; set; }
public BaseClass(){}
public BaseClass(string x) {
result = doThing(x);
}
public virtual string doThing(string x)
{
return x;
}
}
public class DerivedClass : BaseClass
{
public DerivedClass(){}
public DerivedClass(string x):base(x){}
public override string doThing(string x)
{
return "override" + x;
}
}
I'd like for a new DerivedClass("test") to have a result of "overridetest" but it doesn't: it calls the base method of doThing. Am I missing something? Do I need to make an AbstractClass and have both BaseClass and DerivedClass inherit from that, Derived class also overriding methods?