Implementing IEnumerable in C# (Simple Example) – Programming, Pseudocode Example, C# Programming Example
C# C# Console

Implementing IEnumerable in C# (Simple Example)

IEnumerable is the base interface for all collections that can be enumerated.

What is enumerable class in C#?

IEnumerable contains a single method, GetEnumerator, which returns an IEnumerator. IEnumerator provides the ability to iterate through the collection by exposing a Current property and MoveNext and Reset methods.

It is a best practice to implement IEnumerable and IEnumerator on your collection classes to enable the foreach statement.

Example program for IEnumerable in C#.NET

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: