Article From:https://www.cnblogs.com/xwqfa/p/9967365.html

int[] arr={2,10,8,4,12,20,24};
int count=0;
foreach(int key in arr)
{
count+=key;
}
It’s easy to traverse arrays with foreach, but you can also do it with for.
int[] arr={2,10,8,4,12,20,24};
int count=0;
for(int i=0;i<arr.length;i++)
{
count+=arr[i];
}

http://www.xinli001.com/info/100413283

Leave a Reply

Your email address will not be published. Required fields are marked *