foreach (var person in peopleList.Where (person => person.FirstName == "Messi")) {selectPeople.Add (person); }
I'm just wondering if there is a way to simplify this with LINQ.
Instead of looking at all the people, I tried using LINQ to just populate the list with "Messi" ... trying something like ...
var selectPeople = peopleList.Select(x=>x.FirstName=="Messi");
Then I could just add everyone to this list without checking. But it does not work as planned.
Maybe it makes no sense to simplify this expression. But the question seemed to be only to strengthen my LINQ knowledge.
source
share