Both the List.TrueForAll
method and the IEnumerable.All
method can be used to check if all list elements satisfy a given
condition in a collection. However, List.TrueForAll
can be faster than IEnumerable.All
for List
objects. The
performance difference may be minor for small collections, but for large collections, it can be noticeable.
Applies to
What is the potential impact?
We measured at least 4x improvement both in execution time. For more details see the Benchmarks
section from the More
info
tab.