C Sharp Programming/Keywords/foreach
From Wikibooks, the open-content textbooks collection
The foreach keyword identifies a foreach loop.
// example of foreach to iterate over an array public static void Main() { int[] scores = new int [] { 54, 78, 34, 88, 98, 12 }; foreach (int score in scores) { total += score; } int averageScore = total / scores.length; }
| C# Keywords | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Special C# Identifiers | ||||||||||
|