I have two IEnumberable<double>
list.
How can i add the each value of one list to the value in the same position in the other list using Linq?
You can use Enumerable.Zip to do this:
var results = first.Zip(second, (f,s) => f+s);
Note that, if the lists aren't the same length, your results will be the length of the shorter of the two lists (Zip
as written above will add together elements until one sequence ends, then stop...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With