Skip to main content
Journey Uncommon Logo
JourneyUncommon
easyC#foreach and iteratorsSingle-choice MCQ

Why does this throw a runtime exception?

var list = new List<int> { 1, 2, 3 }; foreach (var n in list) { if (n == 2) list.Remove(n); }