Enumerators
An enumerator is an iterator. Enumerators are typically obtained by calling the GetEnumerator method of an object implementing the IEnumerable interface. Container classes typically implement this interface. However, the foreach statement in C# can operate on any object providing such a method, even if it doesn't implement IEnumerable. This interface was expanded into generic version in .NET 2.0.
The following shows a simple use of iterators in C# 2.0:
// explicit version IEnumeratorRead more about this topic: C Sharp Syntax