Hay im trying to find the average of the columns. but i can onli get the average of the rows.

my code is like so . .

for (int l = 0; l < list1.Count; l++)
                {   
                float sum = 0.0F;
                float average = 0.0F;

                    string[] list1Values = list1[l].Split(',');

                    for (int k = 1; k < 6; k++)
                               
                    {
                        sum += float.Parse(list1Values[k]);
                        average = sum / k;
                    }
                    Console.Write("{0}", average);
                }

Any ideas????

I dont know what your list represents. So it would be good to add some code or explanation to the thread.

Check out my code I did yesterday here:
http://www.daniweb.com/software-development/csharp/threads/360495

As you can see Iam creating a dictionary, and use generic list<T> as Value.
This how you can get values of the columns together, and then you can do math operations over them.

my list represents a few strings in the following format:

tr0,-0.1,0.1,0.2
tr1,0.1,0.2,0.3

I need to split them at the (',') and then add column 1

eg -0.1 +0.1 /2 = average

0.1 + 0.2 / 2 = average

What type is your list?
is it: List<double[]> ?

Actualy useing that information at the link i got it working!thank you very much!!!

This question has already been answered. Start a new discussion instead.