I’m not sure if what I’m asking about is possible, so bear with me.
Currently I have multiple functions, each with the same loop bit and different action.
I would like a function who’s main purpose is to loop through certain entries in a list and have different action based on the caller.
One solution I though of is to have a switch/if block and a unique variable from the caller to determine the action. However, I was more thinking along the lines of calling the function and some how passing in the action it should take on each entry.
Perhaps your function could take an
Action<T>as a parameter, and each caller can provide its own action as an argument?You could call it like the following:
Or perhaps like the following:
Or with any other operation you want to perform.