Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#deferred vs immediate LINQSingle-choice MCQ

A method returns `source.Select(x => Transform(x))` over an `IEnumerable<T>` parameter, where `Transform` can throw. A caller wraps only the method call site in a try/catch but still sees the exception escape. Why?

IEnumerable<int> GetItems(IEnumerable<string> src) => src.Select(s => int.Parse(s)); // caller: try { var items = GetItems(input); } catch (FormatException) { /* never reached */ } foreach (var i in items) { /* throws here */ }