Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#yield return generatorsSingle-choice MCQ

What is the result of compiling and running this iterator that has a try/finally with a yield inside the try?

IEnumerable<int> Gen() { try { yield return 1; yield return 2; } finally { Console.Write("F"); } } foreach (var x in Gen()) { Console.Write(x); if (x == 1) break; }