Linq and Lamba Expressions - while walking a selected list perform an action

Posted by Prescott on Stack Overflow See other posts from Stack Overflow or by Prescott
Published on 2010-05-28T18:27:12Z Indexed on 2010/05/28 18:42 UTC
Read the original article Hit count: 331

Filed under:
|

Hey, I'm very new to linq and lamba expressions. I'm trying to walk a collection, and when I find an item that meets some criteria I'd like to add that to another separate collection.

My linq to walk the collection looks like this (this works fine):

From i as MyCustomItem In MyCustomItemCollection Where i.Type = "SomeType" Select i

I need each of the select items to then be added to a ListItemCollection, I know I can assign that linq query to a variable, and then do a for each loop adding a new ListItem to the collection, but I'm trying o find a way to add each item to the new ListItemcollection while walking, not a second loop.

Thanks ~P

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about lambda-expressions