I have this setting:
public class BaseElement
{
public BaseElement() { }
public virtual void method01()
{
Console.WriteLine("class BaseElement method01");
}
}
public class Element01 : BaseElement
{
public Element01() { }
public override void method01()
{
Console.WriteLine("class Element01 method01");
}
}
public class Element02 : BaseElement
{
public Element02() { }
public override void method01()
{
Console.WriteLine("class Element02 method01");
}
}
Now I want to force class Element01/Element02/Element03 and so on to implement method01. I think the correct way is to use an interface. But due to the fact that Element01/Element02/Element03 and so on inherit from BaseElement there is no need to implement method01 in Element01/Element02/Element03 and so on because it is already implemented in BaseElement. But I want to force Element01/Element02/Element03 and so on to implement a specific method01 in each of these classes. On the other hand I need method01 in BaseElement also to address Element01/Element02/Element03 and so on as BaseElement. What would be the best way to do this?
(It has nothing to do with the difference between abstract and virtual functions. I need a specific arrangement of either an interface or an abstract class.)