What is yield return in C#?

gpeipman
20.3K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Yield return in C#

Yield return in C# language feature that allows us to write shorter methods that operate on collections. Demo below shows how with yield return we don't have to define collection or list that holds elements returned by method.

Open Source Your Knowledge: become a Contributor and help others learn. Create New Content