UPDATE Here my update using enums:
First Declare an Enum :
enum ActionType
{
Add,
Subtract
}
Then use that enum in your ActionRegistry class:
public class ActionRegistry: Dictionary<int, Func<int, int, int>>
{
public ActionRegistry()
{
this.Add((int)ActionType.Add, (x, y) => x + y);
this.Add((int)ActionType.Subtract, (x, y) => x - y);
}
}
then you should change your calculate method like this :
private int Calculate(int actionTypeCode)
{
var actionRegistry= new ActionRegistry();
var a = 1;
var b = 2;
//var actionResult= actionRegistry[this should come from your drop down].Invoke(a, b);
var actionResult= actionRegistry[actionTypeCode].Invoke(a, b);
return actionResult;
}
Note that you should bind your dropdown list with your enum keys as value.
I prefer to use an integer as my key because I can add more item later without changing my enum but it is not necessary.