introductory-examples/control-structures/foreach-demo.cs - Demonstrations of foreach. | Lecture 2 - slide 14 : 43 Program 4 |
/* Right, Wrong */ using System; class ForeachDemo { public static void Main(){ int[] ia = {1, 2, 3, 4, 5}; int sum = 0; foreach(int i in ia) sum += i; Console.WriteLine(sum); } }