- IEnumerable interface contains in the System.Collections.Generic namespace.
- IEnumerable interface is generic interface which allows to looping over generic or non-generic list.
- IEnumerable interface also works with linq query expression.
- IEnumerable interface Returns an enumerator that iterates through the collection.
IEnumerable vs IEnumerator interface
- IEnumerable and IEnumerator are both interfaces.
- IEnumerable has just one method called GetEnumerator. This method returns another type which is an interface that interface is IEnumerator.
- if wants to implement enumerator logic in any of collection class, it need to be implement IEnumerable interface (either generic or non-generic).
- IEnumerable has just one method where as IEnumerator has two methods (MoveNext and Reset) and a property Current.
- "Start" - "All Programs" - "Microsoft Visual Studio 2010".
- "File" - "New Project" - "C#" - "Empty Project" (to avoid adding a master page).
- Provide the Project name such as "IEnumerableInterface" or another as you wish and specify the location.
- Then right-click on Solution Explorer and select "Add New Item" then select Default.aspx page.
- Add One Button .
I hope this article is useful for all readers, if you have any suggestion then please contact me including beginners also.