Reputation: 14060
Given a list like this:
["singing", "office", "1995>Work Photos", "Kevin", "and", "Emma", "Holiday Party>Karaoke"]
What's the most concise LINQ query to select the first element in the list that includes the character '>' and all elements after it. For the example above, I'd like this result:
["1995>Work Photos", "Kevin", "and", "Emma", "Holiday Party>Karaoke"]
I could obviously loop through and do it manually but it feels like there's an elegant one-liner out there. Here's the manual attempt:
var found = false;
var filtered = new List<string>();
foreach (var itm in list){
if (itm.Contains(">")) found = true;
if (found) filtered.Add(itm);
}
Console.WriteLine(filtered);
Upvotes: 2
Views: 405