Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用Lambda搜索字符串数组_C#_Lambda - Fatal编程技术网

C# 使用Lambda搜索字符串数组

C# 使用Lambda搜索字符串数组,c#,lambda,C#,Lambda,我有一个通用列表vwsearch,其中有一个字符串字段ProductSearch。和字符串数组stringarray 如何在列表中搜索字符串字段等于或包含数组中所有字符串值的记录。 我有下面的代码,它返回ProductSearch字段包含数组中任何字符串值的记录 vwsearch = vwsearch.Where(v=>v.ProductSearch.Contains(stringarray.Last())) 怎么样 vwsearch = vwsearch.Where(v => s

我有一个通用列表vwsearch,其中有一个字符串字段ProductSearch。和字符串数组stringarray

如何在列表中搜索字符串字段等于或包含数组中所有字符串值的记录。 我有下面的代码,它返回ProductSearch字段包含数组中任何字符串值的记录

vwsearch = vwsearch.Where(v=>v.ProductSearch.Contains(stringarray.Last()))
怎么样

vwsearch = vwsearch.Where(v => stringarray.All(s => v.ProductSearch.Contains(s)))

您的代码是VB.Net,为什么您的问题用C标记,而且您当前的代码不会返回ProductSearch字段包含数组中任何字符串值的记录,而是只返回ProductSearch包含数组中最后一项的记录。