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

An iterator method uses try/finally around its yield statements. When is the finally block guaranteed to run?

static IEnumerable<int> Gen() { try { yield return 1; yield return 2; } finally { Console.WriteLine("cleanup"); } }