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????

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Mark_48

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:

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.

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:

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