I have a list of methods that do pretty much the same thing, except a few differences:
void DoWork(string parameter1, string parameter2)
{
//Common code
...
//Custom code
...
//Common code
...
}
I want to streamline the solution with reusing the common code by passing custom code from another method.
I assume I have to use an action with parameters to accomplish this, but can’t figure out how.
The other answers are great, but you may need to return something from the custom code, so you would need to use Func instead.
Call it like this:
Or: