Adding/summing two arrays

前端 未结 5 1334
抹茶落季
抹茶落季 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 02:59

    Zip it :)

    var a = new int[] {1,2,3 };
    var b = new int[] {4,5,6 };
    a.Zip(b, (x, y) => x + y)
    

提交回复
热议问题