C# Action syntax
c#
Solution
public void Execute(Action action)
{
Write();
action();
Clear();
}
Problem
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?