I have an abstract class:
public abstract class BaseClass
{
protected BaseClass()
{
before();
run();
after();
}
protected abstract void run();
private void before() { }
private void after() { }
}
And the derived class which just overrides abstract run method:
public class DerivedClass
{
public readonly ContextClass a;
public DervidedClass(ContextClass a) =>
this.a = a;
protected override void run()
{
if (a is null)
Console.WrileLine("a is null");
}
}
Logically, when I create an instance of DerivedClass it calls its base constructor. In base constructor it should call before(), run() and after() methods, but when it comes to run() it is being executed with no DerivedClass context as "a" is null here.
It looks like a complete nonsense, so I guess I have an error in my code maybe. I will be grateful for your help.