add together values in collection

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

ASP.NET 2.0

In my webproject I got a class named "Tag".This class contains a variable
named "Weight" of datatype int...

This is a generic list (I assume it is a generic list) of Tag objects
List<Tag> tags = new List<Tag>();

PROBLEM:
I want to add together all the Weight values in the list

I know I could do this in a loop, for example a foreach loop. But I'm
wondering if this could be done without a loop.. Maybe the Generic feature
in .NET 2.0 has some nice feature for this?

(( I have no problem using a loop here, I just ask just in case there is a
smarter way of doing it ))

Any suggestions?

Jeff
 
Back
Top