Steven Giesel 12/16/2021

Generator-Function in C# - What does yield do?

Read Original

This technical article explains the 'yield' keyword in C# for creating generator functions. It provides a detailed code example comparing a lazy IEnumerable generator using 'yield return' with a traditional method that returns a full List, highlighting key differences in execution flow and lazy evaluation. The article discusses practical implications, such as performance benefits when using methods like LINQ's Any().

Generator-Function in C# - What does yield do?

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

1
The Beautiful Web
Jens Oliver Meiert 2 votes
3
LLM Use in the Python Source Code
Miguel Grinberg 1 votes
4
Wagon’s algorithm in Python
John D. Cook 1 votes