Adding/summing two arrays

前端 未结 5 1342
抹茶落季
抹茶落季 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:14

    IList first = new List { 2, 3, 4, 5 };
    IList second = new List { 2, 3, 4, 5 };
    
    var result = Enumerable.Zip(first, second, (a, b) => a + b);
    

提交回复
热议问题