sum

  • Thread starter Thread starter Hrvoje Voda
  • Start date Start date
"Hrvoje Voda" <[email protected]> a écrit dans le message de [email protected]...

| How to make a Sum of listBox items?

Assuming all the items in the listbox are string representations of integers
:

{
int total = 0;

foreach (object o in listbox1.Items)
{
total += (int) Convert.ChangeType(o, typeof(int));
}
}

Joanna
 
"Simon Hart" <srhartone@[no spam]yahoo.com> a écrit dans le message de uEcIlm%[email protected]...


| Or just simply:
|
| int count = listbox.Items.Count;

Huh ? The term Sum means the total of all the values, not the Count.

Joanna
 
Joanna Carter said:
"Simon Hart" <srhartone@[no spam]yahoo.com> a écrit dans le message de
uEcIlm%[email protected]...


| Or just simply:
|
| int count = listbox.Items.Count;

Huh ? The term Sum means the total of all the values, not the Count.

Joanna

Well it depends on context

If I asked for the sum total of items in the list I'd probably be after the
count. but if I asked for the sum of the items I'd probablt be asking got
the the sum across each item in teh list.

The problme is that on an English newsgroup in a heavily non-English
speaking world then both interpretations are valid and the OP needs to
provide more context.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
 
Back
Top