How to update an element with a List using LINQ and C#

Posted by Addie on Stack Overflow See other posts from Stack Overflow or by Addie
Published on 2010-03-15T18:21:09Z Indexed on 2010/03/15 18:29 UTC
Read the original article Hit count: 281

Filed under:
|
|

I have a list of objects and I'd like to update a particular member variable within one of the objects. I understand LINQ is designed for query and not meant to update lists of immutable data. What would be the best way to accomplish this? I do not need to use LINQ for the solution if it is not most efficient.

Would creating an Update extension method work? If so how would I go about doing that?

EXAMPLE:
(from trade in CrudeBalancedList
 where trade.Date.Month == monthIndex
 select trade).Update(
 trade => trade.Buy += optionQty);

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ