I need to check if a sequence has any items satisfying some condition but at the same time NOT all items satisfying the same condition.
For example, for a sequence of 10 items I want to have TRUE if the sequence has at least one that satisfy the condition but not all:
- 10 items satisfying, 0 items not, result is FALSE
- 0 items satisfying, 10 items not, result is FALSE
- 1 item satisfying, 9 items not, result is TRUE
- 9 items satisfying, 1 item not, result is TRUE
I know I could to this:
mySequence.Any (item => item.SomeStatus == SomeConst) && !mySequence.All (item => item.SomeStatus == SomeConst)
But this is not optimal.
Is there a better way?