Both the Enumerable.First
extension method and the LinkedList<T>.First
property can be used to find the first value
in a LinkedList<T>
. However, LinkedList<T>.First
is much faster than Enumerable.First
. For small
collections, the performance difference may be minor, but for large collections, it can be noticeable. The same applies for the Last
property as well.
Applies to:
What is the potential impact?
We measured a significant improvement both in execution time and memory allocation. For more details see the Benchmarks
section from
the More info
tab.