Given:
int[] numbers = {0, 1, 2, 3, 4}; Func<int, bool> isOdd = i => i % 2 != 0; Func<int, bool> isZero = i => i == 0; |
Instead of having:
Func<int, bool> isZeroOrOdd = i => isZero(i) || isOdd(i); |
We could have:
Func<int, bool> isZeroOrOdd = isZero || isOdd; |
2- Same thing but with expressions:
Given:
Expression<Func<int, bool>> isOdd = i => i % 2 != 0; Expression<Func<int, bool>> isZero = i => i == 0; |
It would be great to have:
Expression<Func<int, bool>> isZeroOrOdd = isZero || isOdd |
which would then result into a new binary expression (OR) from the two isZero and isOdd expressions.

Additional lambda expressions support
Duppi
Paulo Sebastiao
I think we should do this too. Maybe I'll just slip it in while everyone else is asleep
yyjtrip
JeremiahMetzen
Personally, I like the syntax. It reminds me of operator math from my quantum physics classes in college.
Saranya
This breaks quickly in the multivariate case:
Given foo(int, int) and bar(int, int),
Baz = foo [op] bar
could generate
foo(a, b) [op] bar(a, b)
when it is entirely possible to want
foo(a, b) [op] bar(b, a)
Phil333
Func<int, int, bool> foo = (i,j) => i == j;
Func<int, int, bool> bar = (i, j) => i % j == 0;
Func<int, int, bool> baz = (i,j) => foo(i,j) || bar(j,i);
It would me awesome it the equivalent for expressions could exist:
Expression<Func<int, int, bool>> fooExpression = (i,j) => i == j;
Expression<Func<int, int, bool>> barExpression = (i, j) => i % j == 0;
Expression<Func<int, int, bool>> bazExpression = (i,j) => foo(i,j) || bar(j,i);
But there are currently no other ways to create the bazExpression than to create the expression tree manually by creating a new BinaryExpression with the foo, bar as parameters, ...