By using the foreach statement you can iterate elements of a collection without the need to know the number of elements inside the collection. The foreach statement uses an enumerator. Figure 5-7shows the relationship between the client invoking the foreach method and the collection. The array or collection implements the IEnUlll9rable interface with the GetEnumerator () method. The…