Adding/summing two arrays

前端 未结 5 1343
抹茶落季
抹茶落季 2021-01-31 02:51

I\'ve encountered a purely hypothetical problem which feels like it has an easy solution if I find the right linq method...

I have two arrays of ints and I know they are

5条回答
  •  春和景丽
    2021-01-31 03:03

    You can use the Select method.

    int[] a = new[] { 1, 2, 3 };
    int[] b = new[] { 10, 20, 30 };
    
    var c = a.Select ((x, index) => x + b[index]).ToArray();
    

提交回复
热议问题