What will be printed out as a result of the following program execution?
class Program
    static IEnumerable<char> GetLetters()
        yield return 'A'; 
        yield return 'B'; 
        yield return 'C'; 
    static void Main(string[] args)
       foreach(char ch in GetLetters())
GetLetters() function creates an iterator over char type objects.
yield return statement indicates the compiler the value returned by an iterator on a current iteration. Execution continues from the next operator on the following iteration.
More can be found here: https://msdn.microsoft.com/en-us/library/dscyy5s0.aspx
C# Quiz
Start Quiz

or Read more about C# Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback