【发布时间】:2021-11-04 00:54:50
【问题描述】:
我想用所需的 id 删除它。
你能告诉我是否有其他方法可以用 Linq 做到这一点吗?
我想我可以使用 Select() 和 Where(),但它不起作用。
var list = new List<object>() { };
list.Add(new { id = 3, const = "22"});
list.Add(new { id = 4, const = "22"});
list.Add(new { id = 6, const = "22"});
list.Add(new { id = 2, const = "22"});
list.Add(new { id = 1, const = "22"});
//example
list.Remove(new { id = 2, const = "22" });
【问题讨论】:
-
你能比
doesn't work更具体吗?甚至可能包括“不起作用”的代码?欢迎来到stackoverflow。我推荐taking the tour,以及阅读how to ask a good question 和what's on topic。 -
我以示例格式编写了我想做的代码。
标签: c# list listobject