public
class Calculator
![](http://static.javashuo.com/static/loading.gif)
{
static
private Dictionary<OPERATOR, Func<
int,
int,
int>> calculationAction =
new Dictionary<OPERATOR, Func<
int,
int,
int>> {
![](http://static.javashuo.com/static/loading.gif)
{ OPERATOR.Add, Add },
![](http://static.javashuo.com/static/loading.gif)
{ OPERATOR.Minus, Minus },
![](http://static.javashuo.com/static/loading.gif)
{ OPERATOR.Multiply, Multiply },
![](http://static.javashuo.com/static/loading.gif)
{ OPERATOR.Divide, Divide }
![](http://static.javashuo.com/static/loading.gif)
};
public
static OPERATOR GetOperator2(
char ch)
![](http://static.javashuo.com/static/loading.gif)
{
if (OperatorMap.ContainsKey(ch))
return OperatorMap[ch];
else
return OPERATOR.Unknown;
![](http://static.javashuo.com/static/loading.gif)
}
static
int Add(
int number1,
int number2)
![](http://static.javashuo.com/static/loading.gif)
{
return number1 + number2;
![](http://static.javashuo.com/static/loading.gif)
}
// Others are omitted here for brevity
![](http://static.javashuo.com/static/loading.gif)
}