Skip to content
Preptima
mediumCodingConceptMidSenior

You build a LINQ query, then change the list it came from, then enumerate it. What do you get?

5 min readUpdated 2026-08-15Target archetype: Big Tech, Enterprise Captive, Product Startup

Answer

Short answer

The results reflect the list and the captured variables as they are at enumeration time, not at query construction, because a LINQ-to-objects query is an iterator holding references rather than a snapshot.

Was this answer helpful?

Likely follow-ups

  • Any followed by First on the same query. What does that cost, and what would you write instead?
  • Which standard operators must consume the whole sequence before they can yield anything, and why?
  • A method returns IEnumerable built with yield return and the caller enumerates it twice. What happens?
  • What changes about all of this once the query is an IQueryable against a database?

Related questions

Further reading