Friday, March 16, 2012

Median/Average of a parameter in an arraylist

Hi,
I was just wondering if there was an easy way of getting an average/median of a parameter in a class which is stored in an array list.

You could do something like

Total = 0
For each Element
Total = Total + Element.Value
End For
Average = Total/Element.Count

but is there another way?

Thanks in advance

AuschuckyI use the same method as yours to get the averageSmile [:)]
Me tooSmile [:)]

Probably you did it, if not, consider to create an Utilities class with a public static function (called "average"?) that does this, so you can use it everywhere in your applicattion
Thanks for that.

I've implemented an average function in a utilites class that works great!

Auschucky

0 comments:

Post a Comment