I'm able to compile code that includes this:
OperationDelegate myOpDelegate;
static OperatorDefinition[] definitions ={
new OperatorDefinition("+",2,3,true, new OperationDelegate(OperationAdd)),
};
delegate double OperationDelegate(double[] args);
static double OperationAdd(double[] args)
{
return args[0] + args[1];
}
but I think my code would look cleaner if I could do something more like this:
OperationDelegate myOpDelegate;
static OperatorDefinition[] definitions ={new OperatorDefinition("+",2,3,true, new OperationDelegate({return args[0]+args[1]}))};
delegate double OperationDelegate(double[] args);
because I want to define everything about each OperatorDefinition in a single place, rather than defining the functions separately. Is there some way to do this in C#?
(any other criticism about my code would be welcome, too)