更新时间:2023-02-13 11:18:54
LINQ用于查询,而不用于更新数据.使用LINQ获取要修改的项目,然后在foreach
循环中对其进行修改:
LINQ is for querying, not for updating the data. Use LINQ to get the items that you want to modify, and then modify them in a foreach
loop:
foreach ( var tom in myList.Where(w => w.Name == "Tom")) {
tom.Marks = 35;
}