Is there a generic constraint I could use for the + operator?

There are no such devices in C#. A few options are available, though:

So either:

return (dynamic)left.Evaluate(context) + (dynamic)right.Evaluate(context);

or

return Operator.Add(left.Evaluate(context), right.Evaluate(context));

Leave a Comment