Most systems don’t need all data right now. They need “the next item,” then the next, and so on. That’s the essence of the generator style in C#: produce a sequence lazily—only when the consumer asks—using yield and the iterator interfaces.
The “Generator” Pattern in C# — Produce Data…
Most systems don’t need all data right now. They need “the next item,” then the next, and so on. That’s the essence of the generator style in C#: produce a sequence lazily—only when the consumer asks—using yield and the iterator interfaces.