Foreach loop
Foreach loop is used to iterate over the elements of the collection. The collection may be an array or a list. Foreach loop iterates through each element present inside array hence it is called as foreach loop. Foreach loop will only work on collection of values.
CODE
EG 1 . Creating an array called musical instruments and printing out all elements in console using foreach loop
static void Main(string[] args) {
    string[] musicalInstruments = { "piano", "guitar", "violin", "drums" };
    foreach (string musicalInstrument in musicalInstruments) {
        Console.WriteLine(musicalInstrument);
    }
}
EG 2 . Calculating total number of '$' present inside char[]
static void Main(string[] args) {
    char[] symbols = { '@', '$', '%', '&', ')', '(', '$', ')', 'P', '8', '$', '%' };
    int dollerCount = 0;
    foreach (char symbol in symbols) {
        //Inside if statement, if you going to have only one line of code then there is no need for writing { and }
        if (symbol == '$') dollerCount++;
    }
    Console.WriteLine("The number of $ present inside array is " + dollerCount); // Output : The number of $ present inside array is 3
}
(Click Here, For more exercises)