c# List 按条件查找、删除

 1 public class People
 2  {
 3        public string Name;
 4        public DataTime Birthday;
 5        public string Tel;    
 6   }
 7  
 8  List<People> peopleList = new List<People>();
 9 
10 // 按条件查找
11 
12 peopleList.Find(e=>e.Name == "姓名");  // 返回第一个与条件匹配的项
13 
14 // 按条件删除
15 
16 peopleList.Remove(e=>e.Name == "姓名");    // 删除第一个与条件匹配的项

 

posted @ 2020-11-07 10:25  llkj  阅读(2541)  评论(0编辑  收藏  举报