Namespace: System.Collections
The IEnumerable interface is the base interface for all collection types in the .NET Framework. It provides a way to iterate over a collection, one element at a time.
The IEnumerable interface represents a generic collection that can be enumerated. It is implemented by classes such as List<T>, Dictionary<TKey, TValue>, and arrays.
GetEnumerator()Returns an enumerator that iterates through a collection.
An IEnumerator object that can be used to iterate through the collection.
The IEnumerable interface is the foundation for iterating over collections in C#. When you use a foreach loop in C#, the compiler generates code that calls the GetEnumerator() method of the collection to obtain an enumerator, and then uses the IEnumerator interface to step through the collection's elements.
If a collection implements IEnumerable, it means that you can iterate over its elements using a foreach loop.
mscorlib.dll
System.Collections
The following C# code example demonstrates how to use a collection that implements IEnumerable with a foreach loop.