Suppose I have the following:
var a1 = new [] { 2, 7, 9 }; var a2 = new [] { 6, 3, 6 };
I want to end up with:
var sum = new [] { 8, 10, 15 };
What is the fastest way to get there?
You can use Zip():
Zip()
var res = a1.Zip(a2, (x, y) => x + y).ToArray();
Alternatively, you can use Select():
Select()
var res = a1.Select((x, i) => x + a2[i]).ToArray();
Source: https://habr.com/ru/post/1670875/More articles:ios: universal links not working on iOS 10 - iosNGINX - Session Management with NGINX as an API Gateway - reverse-proxyhost github pages from the / dist folder in the main branch - githubSetting the environment variable to Ansible from the output of the bash command - bashCount the number of occurrences - rDisplay image of a binary PNG file stored in MongoDB - pythonError CoreAudio - AVAudioIONodeImpl.mm//65: _GetHWFormat: Required false: hwFormat - iosHide MATLAB legend entries for some graphical objects on graphs - matlabСтруктурирование хранилища состояний (ngrx/redux). Плоская как представитель данных, или вложенная как представительница взгляда? - stateКак предотвратить тип TypeError: неподдерживаемый тип операндов для -: "NoneType" и "int" при использовании keras EarlyStopping? - pythonAll Articles