IEnumerable And IEnumerator interfaces
Before continuing, let me explain the structure, members of the IEnumerable , IEnumerator interfaces. The IEnumerable interface contains an abstract member function called GetEnumerator() and return an interface IEnumerator on any success call. This IEnumerator interface will allow us to iterate through any custom collection. Note: IEnumerator interface is meant to be used as accessors and is not helpful to make any changes in the collection or elements of the collection. Presumably, any element in a collection can be retrieved through its index property. But instead of element index, the IEnumerator provides two abstract methods and a property to pull a particular element in a collection. And they are Reset() , MoveNext() and Current . See the figure. This is how it works. Members of IEnumerator Interface Reset(), MoveNext(), Current() The...