What are the benefits of a Deferred Execution in LINQ?

Technology CommunityCategory: LINQWhat are the benefits of a Deferred Execution in LINQ?
VietMX Staff asked 3 years ago

Deferred execution means that the evaluation of an expression is delayed until its realized value is actually required. Deferred execution can greatly improve performance when you have to manipulate large data collections, especially in programs that contain a series of chained queries or manipulations. In the best case, deferred execution enables only a single iteration through the source collection.

Deferred execution is supported directly in the C# language by the yield keyword (in the form of the yield-return statement) when used within an iterator block.