Foreach, IEnumerable and IEnumerator in C#

Highlighted image - laptop and monitors with code at them

Today, we’re taking a deeper look at foreach loop in C#. What does a collection need to be able to use it in a foreach loop? Does it have to implement IEnumerable interface? These questions are often asked during interviews, so it’s worth knowing the answers 😃

We will go through a step-by-step example in building our own custom collection to see how all that works. Let’s dive in! 😎