What is the best way to reuse switch logic. I have this switch statement that keeps appearing in my code. Rather then copy paste it I would like to make a function that calls other delegates and pass these delegates in as parameters.
Or is there a better way?
Function 1:
switch (test)
{
case "x":
DoSomethingX();
break;
case "y":
DoSomethingY();
break;
case "z":
DoSomethingZ();
break;
}
Function 2:
switch (test)
{
case "x":
DoSomethingXxxx();
break;
case "y":
DoSomethingYyyy();
break;
case "z":
DoSomethingZyyy();
break;
}