C# 使用 LINQ 和 Foreach 修改 List<T> 中第一个 name 为 'a' 的数据
在 C# 中,可以使用 LINQ 和 'ForEach' 方法来实现修改 List
以下是示例代码:
myList.FirstOrDefault(item => item.Name == 'a')?.Name = "newName";
上述代码中,'myList' 是一个 List
请注意,这里假设 List
原文地址: https://www.cveoy.top/t/topic/qn85 著作权归作者所有。请勿转载和采集!