How to check two IEnumerables whether they have same count without running through them individually. Means I do not want to do this Count() == Count().
I would like to find a way to do that in one pass. Any ideas?
How to check two IEnumerables whether they have same count without running through them individually. Means I do not want to do this Count() == Count().
I would like to find a way to do that in one pass. Any ideas?
This is not possible. Whatever approach you choose, you will have to run through both sequences.
The most straightforward way is to use the Count()
method, where would be an O(1)
if both sequences are List
. In this case, the Count()
fails to get the value of list's property called Count
.