I can’t seem to apply binary operations to lambda expressions, delegates and method groups.
dynamic MyObject = new MyDynamicClass();
MyObject >>= () => 1 + 1;
The second line gives me error: Operator '>>=' cannot be applied to operands of type 'dynamic' and 'lambda expression'
Why?
Isn’t the operator functionality determined by my custom TryBinaryOperation override?
It’s not an issue with
MyDynamicClass, the problem is that you can’t have a lambda expression as a dynamic. This however, does appear to work:If the
TryBinaryOperationlooks like this:Then
resultwill be 2. You can usebinder.Operationto determine which binary operation this is.