Get the latest tech news
Net 9.0 LINQ Performance Improvements
Understand .NET 9.0 LINQ performance improvements, faster iterator and the usage of Span
October 17, 20245 minutes read NET 9.0 brings significant improvements to LINQ performance, with some scenarios showing remarkable gains. However, since holding the internal array of a list obtained via CollectionsMarshal.AsSpan() is not a safe option (as mentioned earlier), certain Enumerable operations that defer iteration (like when using the yield C# keyword) cannot rely on this optimization. If you have the opportunity, I highly recommend watching the DeepDotnet videos featuring Scott Hanselman and Stephen Toub.
Or read this on Hacker News