|
Listing 15-1 extracted from chapter
Collections
Listing 14-50< > Listing 15-2
This listing can be compiled with the command line: csc.exe /target:exe Example_15_1.cs Errors: 0 Warnings: 0
Example_15_1.cs
using System;
class Program {
static void Main() {
int[] arr = { 1, 3, 4, 8, 2 };
// Compute the sum of items.
int sum = 0;
foreach ( int i in arr )
sum += i;
// Here the sum is equal to: 1+3+4+8+2 = 18
}
}
Copyright Patrick Smacchia 2006 2007
|