If I have an array of integers, how can I automatically find the sum of the array?
Iteratively sum the elements, like this:
public int SumArray(int[] toBeSummed)
{
int sum = 0;
foreach (int item in toBeSummed)
{
sum += item;
}
return sum;
}
Something like this:
var ints : int[];
var total : int;
function Awake () {
for(var i = 0; i<ints.length; i++){
total += ints*;*
}
}