I have a list of objects of the same type, each of which has a property, which is an array of floats. Taking this list as input, what is the easiest way to return a new array, which is the average number of arrays in the list?
Input objects are as follows:
Class MyDatas
{
float [] DataValues;
}
...
List<MyDatas> InputList;
float [] result;
Arrays of DataValues will have the same length. Each element of the result array will be the average of the corresponding elements in the array of each member of the list. For instance:result[0] = (InputList[0].DataValues[0] + InputList[1].DataValues[0] + ... ) / InputList.Count
Of course, I could overdo this with foreach inside the for loop, and then for the for loop after that, but it seems to me that this should be done with one or two LINQ lines. Any tips?