I have two string arrays; one listand the otherfind
I want to be able to count the number of elements in a search that are partially contained in a "list" using extension and linq methods. Here is a summary of how I will do this in several nested loops:
int Count = 0;
foreach (string f in find)
{
foreach (string l in list)
{
if (l.Contains(f))
{
Count++;
break;
}
}
}
return Count;
I would like to do something like:
int Count = list.Select(...);
In my actual application, listis an element in the linq type request IQueryable<string>and findis static string[]. I would like to be able to execute the account above in linq. I know that I will probably have to use it .AsEnumerable(), since any solution probably cannot be translated into SQL.
Shawn source
share