C# List集合 where的用法

1、单个条件

   //Name是传入的参数值
List<Test> list = new List<Test>(); list = list.Where(a => a.testName.Contains(Name)).ToList();

2、多个条件合并查询

  //Number_Name是传入的参数值
  List<Test> list = new List<Test>();
  list = list.Where(a => a.testNumber.Contains(Number_Name) || a.testName.Contains(Number_Name)).ToList();
//
  List<Test> list = new List<Test>();
  list = list.Where(a => a.testNumber.Contains(Number_Name) && a.testName.Contains(Number_Name)).ToList();
posted @ 2022-05-26 11:42  南国之恋  阅读(2351)  评论(0编辑  收藏  举报