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