Thursday, November 26, 2009

LINQ objects, how easy and usefull is this!


I try to use new usefull features from .NET 3.0/3.5 more often.
 
Today I needed to calculate a sum for objects in a List.

Always before I used foreach loops, but in .NET 3.5 I have LINQ. 
I can calculate my result this way:


var anteileSume = stoffList.Distinct().Sum(stoff => stoff.Anteil);




This is just great! :)


Very helpfull list of LINQ samples I found here on MSDN .

No comments:

Post a Comment