Back to notes -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    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);
  }      
}