C# Programming/Keywords/foreach
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 };
int total = 0;
foreach (int score in scores) {
total += score;
}
int averageScore = total/scores.Length;
}
C# Keywords | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Special C# Identifiers (Contextual Keywords) | |||||||||||||||
| |||||||||||||||
Contextual Keywords (Used in Queries) | |||||||||||||||
|