Check out example codes for "c# yield". It will help you in understanding the concepts better.

Code Example 1

using System;
using System.Collections.Generic;

public class YieldSample
{
    static void Main()
    {
        foreach (var number in GenerateWithoutYield())
            Console.WriteLine(number);
    }
    public static IEnumerable<int> GenerateWithoutYield()
    {
        var i = 0;
        var list = new List<int>();
      
        while (i < 5)  // yield gives the control to this part and will hit only this part everytime we call GenerateWithoutYield
            yield return ++i;

    }
}

Learn ReactJs, React Native from akashmittal.com