Skip to main content
InterviewHubPRO
Section Overview
Q44

Question 44 of 50

Part 3: CLR Internals, Native AOT & Production Diagnostics (25 - 35)

88%
C# & CLR Internals (50 Qs)•Part 3: CLR Internals, Native AOT & Production Diagnostics (25 - 35)

LINQ Internals and Deferred Execution Traps.

senior LevelcsharpCLR Internals

In Simple Words: LINQ uses Deferred (Lazy) Execution: query execution does not occur when the LINQ query is defined, but when enumerated (foreach, .ToList(), .Count()):

  • Multiple Enumeration Bug: Calling .Count() and then .ToList() on an IEnumerable that executes an HTTP request or DB query executes the expensive operation twice! Materialize with .ToList() or .ToArray() before multiple uses.