473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

add together values in collection

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<Tagtags = 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

Mar 7 '07 #1
2 947
You can "clean up" the iterator code a little:
http://www.mattberther.com/?p=540

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OW**************@TK2MSFTNGP05.phx.gbl...
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<Tagtags = 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



Mar 7 '07 #2
Ooppps

Wrong link..

Try

http://www.mattberther.com/?p=592


"sloan" <sl***@ipass.netwrote in message
news:Od**************@TK2MSFTNGP06.phx.gbl...
You can "clean up" the iterator code a little:
http://www.mattberther.com/?p=540

"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:OW**************@TK2MSFTNGP05.phx.gbl...
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<Tagtags = 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



Mar 7 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Sunny K | last post by:
Hi guys, I have a field in my DB called EventDate as a DateTime field, therefore it holds both the date and time together like this: '2004-10-14 08:42:57.000'. I need to add together all the...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
15
by: crjunk | last post by:
I have 4 TextBoxes on my form that I'm trying to add together to get a grand total. Here is the code I'm using: <SCRIPT LANGUAGE="JavaScript"> <!-- Beginning of JavaScript - function...
2
by: Balamurukan | last post by:
How to retrive property values from our own property window
2
by: Matthias S. | last post by:
Hi, I'm just wondering about the easiest way to copy certain values from a collection to a simple array. Say I've got a class (RaceCarDriver) with a DateFirstRace property. Now I'd like to...
1
by: the friendly display name | last post by:
Hello, I need to dynamicaly populate a second listbox, based on the value, that the user has chosen in the first listbox. A good example of what i mean, is this site: ...
4
by: metaperl | last post by:
Hi, I wrote a Forms program which toggles a label each time you click it: private void button1_Click(object sender, EventArgs e) { label1.Text = (label1.Text == "hello") ? "goodbye" : "hello" ;...
11
by: J.Evans.1970 | last post by:
Hello. I've got a table I'm trying to tie to two other tables. The problem is that there is nothing distinct between the 3 tables. Yes, I know... But this is what I have to work with. Let me...
0
by: saheli | last post by:
In my C# project i call a VB 6.0 .dll which in turn returns a load of information. Most of this information is readable. However, some of the information returned is of type VBA.CollectionClass. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.