I have two methods like this:
public void ExecuteA()
{
    Write();
    // A specific work
    Clear();
}
public void ExecuteB()
{
    Write();
    // B specific work
    Clear();
}
I want to extract the Write() and Clear() methods to a new method (Action) to have something like this:
public ASpecificWork()
{
    // do A work
}
public BSpecificWork()
{
    // do B work
}
Execute(BSpecificWork);
Execute(ASpecificWork);
The Write() and Clear() will be defined in Execute() just one time.
What's the right syntax to do so?
public void Execute(Action action)
{
    Write();
    action();
    Clear();
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With