Streaming vs buffering operators
Context: Streaming operators yield results one by one as they iterate over the source. Buffering operators consume the entire source before producing any result.
Streaming operators
Section titled “Streaming operators”Where, Select, Take, Skip, SelectMany (they process elements on‑the‑fly).
var streaming = numbers.Where(n => n > 2); // yields one by oneBuffering operators
Section titled “Buffering operators”OrderBy, GroupBy, Distinct, Reverse (need all data to work).
var buffered = numbers.OrderBy(n => n); // reads all numbers firstReal-world usage example
Section titled “Real-world usage example”Large data sets: Use streaming operators to avoid loading everything into memory. Avoid OrderBy on huge collections unless necessary.
Example: In System.Reactive (Rx.NET), streaming operators are used for infinite sequences.