Suppose I have two lists of strings, List1 and list2, where List1 is a property of an object of type Foo in a list fooList.
I would like to remove a given Foo if no string in foo.List1 matches any string in list2 a la RemoveAll.
I can do this with nested for loops, but is there a way to do this with a single slick LINQ expression?
Long-winded code, building a new list rather than removing stuff from the existing list:
var newFooList = new List<Foo>
foreach (Foo f in fooList)
{
bool found = false;
foreach (string s in newFooList)
{
if (f.FooStringList.Contains(s))
{
found = true;
break;
}
}
if (found)
newFooList.Add(f);
}