blah blah blah is here! blah blah » Close

up1down
link

I want to filter a List<int> collection for all items that are greater than 10.

I know I can simply do:

for(int x = 0; x < myList.Count;x++)

{
if(x < 10)
continue;

newList.Add(x);
}


But I was hoping to do it using those fancy linq query expressions (lambda/linq).

last answered 2 years ago

1 answers

link

linq would look something like this:

List<int> newList = (from x in myList where x < 10 select x).ToList();

Codo
84

I have absolutely fallen in love with Linq. I actually saw the title of this question and said to myself 'I bet there's a way to do that with Linq'

Feedback