linq: how to transform list by performing calculations on every element

Posted by bzamfir on Stack Overflow See other posts from Stack Overflow or by bzamfir
Published on 2010-06-08T07:41:57Z Indexed on 2010/06/08 7:52 UTC
Read the original article Hit count: 255

Filed under:
|
|
|

Hi,

I have a class

Class MyObject
{
    decimal v1;
    decimal dv1;
    decimal v2;
    decimal dv2;
}

and a

List<MyObject> ...

I need to process every element of the list by adding dv1 to v1 and dv2 to v2 Something like (pseudo-syntax):

myList.Transform(o=>o.v1+=o.dv1, o.v2+=o.dv2)

How can I do this (obvious my pseudo-syntax doesn't works)?

Thank you

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ