C# List集合 where的用法

 

1、单个条件

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

2、多个条件合并查询

  //Number_Name是传入的参数值
  List list = new List();
  list = list.Where(a => a.testNumber.Contains(Number_Name) || a.testName.Contains(Number_Name)).ToList();
//
  List list = new List();
  list = list.Where(a => a.testNumber.Contains(Number_Name) && a.testName.Contains(Number_Name)).ToList();

 

转载于:https://www.cnblogs.com/-Fly/p/7765517.html

你可能感兴趣的:(C# List集合 where的用法)