I'm writing a console calculator on c#. I need the following code start working:
Dictionary<string, Delegate> functions = new Dictionary<string, Delegate>();
private void AddMyFunction (Delegate d, string name)
{
if (name == null)
{
name = d.Method.Name;
}
functions.Add (name, d);
}
public void AddFunction (Func<decimal, decimal> f, string name)
{
AddMyFunction (f, name);
}
public void AddFunction (Func<decimal, decimal, decimal> f, string name)
{
AddMyFunction (f, name);
}
public double PerformOperation (string op, decimal x)
{
return functions [ op ] (x);
}
In the function "PerformOperation" the error: "Method name expected" comes out. Please help someone.