'VB.NET - How to add element1 to element2 and add sum of element1 and 2 with element 3 in an array

I can't quite explain it, but this is what I'm trying to do.

Array1 = {1, 5, 7, 4}

0+1 = 1
1+5 = 6
6+7 = 13
13+4 = 17

Array2 = {1, 6, 13, 17}

I still cant figure out how to write the code.



Solution 1:[1]

Okay my bad, I was just being stupid. I found the solution to my answer and it turned out to be something really simple. Thanks to the folks in the comment section.

Dim Array1 As Integer() = {1, 5, 7, 4}
Dim Array2 As Integer() = {0}
For i As Integer = 0 To Array1.Length - 1

'.Add() isnt real, so i made an extension
Array2.Add(Array2(i) + Array1(i))
Next

'to remove the 0 at the start
Array2 = Array2.Skip(1).ToArray

Honestly, I don't know how this did not arrive in my head.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lenin