What is the difference between IEnumerable and IEnumerator?
Ask by ICSM Computer
Updated 25 Jun 2025
Answer:
IEnumerable<T>: ExposesGetEnumerator()to iterate a collection.IEnumerator<T>: Implements actual iteration logic (MoveNext(),Current,Reset()).Use
IEnumerable<T>for returning collections,IEnumerator<T>for building custom iterators.