Important Points:
🔸 The foreach loop iterate only in forward direction.
🔸 Performance wise foreach loop takes much time as compared with for loop.
🔸 Because internally it uses extra memory space as well as.
🔸 The foreach loop use
GetEnumarator() method of the IEnumerable interface. So, the foreach loop can be used with any class that has implemented the interface.🔸 Exit the foreach loop by using break, return, Goto and throw.
The following example demonstrates the foreach loop on a dictionary collection.