I have a list of numeric arrays of same sizes. Is it possible to calculate sum of their 1st, 2nd, ..., n-th elements without using for-loops?
This is my code that does it using loops:
static void Main(string[] args)
{
List<int[]> list = new List<int[]>();
int n = 4;
list.Add(new int[] { 1, 2, 3, 4 });
list.Add(new int[] { 5, 6, 6, 7 });
list.Add(new int[] { 8, 9, 10, 11 });
int[] sum = new int[n];
foreach (int[] array in list)
for (int i = 0; i < n; i++)
sum[i] += array[i];
foreach (int value in sum)
Console.Write($"{value} ");
Console.Read();
}