1、where()用法:必须加条件,且返回对象结果。
string[] arrays={"asd","abc","bbb","ccc"}; var results = arrays.Where(a=>a.Contains("b"));//必须加条件,返回对象
2、select()用法:(1)(a=>a.Value=="22")加条件查询时,返回bool型结果;(2)(a=>a)没条件返回对象
string[] arrays={"asd","abc","bbb","ccc"}; var results = arrays.Select(a => a.Contains("b"));//1、(a=>a.Value=="22")加条件查询时,返回bool型结果
string[] arrays={"asd","abc","bbb","ccc"}; var results = arrays.Select(a => a);//1、(a=>a)没条件,返回所有对象;
结论:
select在linq中一般会用来提取最后筛选的元素集合,在lambda表达式中通常用where得到元素集合
标签:返回,abc,C#,results,arrays,where,select From: https://www.cnblogs.com/kissingthefire/p/17376744.html