.Where()
call CS-R1046The expression .Where(predicate).Count()
returns the number of elements satisfying the predicate. However, this entire expression can be simplified by dropping the .Where()
call and directly passing the predicate to .Count()
. This is more concise and succinct.
var count = arr.Where(x => x % 5 == 0).Count();
var count = arr.Count(x => x % 2 == 0);