I could not find or figure out similar LINQ example.
For the example, I have 2 lists:
List<List<string>> cases = new List<List<string>>()
{
new List<string>() { "a", "c", "b", "w", "z" },
new List<string>() { "s", "c", "b", "w", "z" },
new List<string>() { "t", "c", "b", "w", "z" },
new List<string>() { "u", "c", "b", "w", "z" },
};
and
List<List<string>> pairs = new List<List<string>>()
{
new List<string>() { "a", "r" },
new List<string>() { "a", "f" },
new List<string>() { "u", "f" },
new List<string>() { "u", "z" },
};
I need to get cases
that contains all elements of ANY of pairs
. How to do it with LINQ?
My best try is:
var res = pairs.Where(x => cases.All(y => x.All(z => y.IndexOf(z) >= 0))).ToList();
But gives no results :/