以下代码将抛出运行时异常“Collection was modified; enumeration operation may not execute.”
List<string> l = new List<string>();
l.Add("a");
l.Add("b");
l.Add("c");
foreach (string s in l.Where(s => s.CompareTo("a")>0))
l.Remove(s);
最佳答案
关于c# - 如何使用 LINQ 删除符合特定条件的列表子集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8556409/