Negating Func in lambda expression
Func<T, bool> expr = x => x.Prop != 1;
somelist = somelist.Where(expr);
So far so good. But I would like to negate expr like this:
somelist = somelist.Where(!expr);
Which result in a compile error: Cannot apply ! operator to operand of
type Func<SENTINEL_OPERATION_ACTIVITY, bool>.
Do I have to create another expression variable for this?
Func<T, bool> expr2 = x => x.Prop == 1;
No comments:
Post a Comment