Having a list of models:
List<string> models = new List<string>
{
"abcd1234",
"xycd9999",
"zzz999z",
"ros7777"
};
Having a filterer list:
List<string> filterer = new List<string>
{
"cd",
"9999"
};
I am trying using LINQ to get all the models that contains as part of their name the filterer items.
For this example:
- "abcd1234" and "xycd9999" contains "cd"
- "xycd9999" contains "9999"
therefore the LINQ operation will return a list of the two items: "abcd1234" and "xycd9999".
var filteredList = models
.Where(m => m.Contains("/*HERE WILL BE THE FILTERER ITEMS*/"))
.Distinct()
.ToList();
What is the correct syntax?