< C Sharp Programming < Keywords
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 (Contextual Keywords) | |||||||||||||||
| |||||||||||||||
Contextual Keywords (Used in Queries) | |||||||||||||||
|
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.