Why doesn't it handle all conditions?

I am reading the answer to this question: ( Is there a better way to call LINQ Any + NOT All? ). Why doesn't it handle all conditions? Sorry for posting a new question, but I don't have enough reputation to add a comment to the original question.

 var anyButNotAll = mySequence
.Select(item => item.SomeStatus == SomeConst)
.Distinct()
.Take(2)
.Count() == 2;

      

+3


source to share


1 answer


If the condition is always false (or always true), then when projecting the sequence using the condition and call, there Distinct

will be 1 result, not two, therefore, it Count() == 2

will return false, not true.



+2


source







All Articles