C# Yield

Posted by Joe Enos on June 29, 2021 · 1 min read

When building a method that returns IEnumerable, you can use the yield keyword to return results one at a time, rather than returning a full collection. This is useful if your collection would be very large, or if you want results as fast as you can rather than waiting.

View code on GitHub