Tag: c#

Jun 27

C# Custom Enumerators Made Simple with the Yield Keyword

An enumerator enables you to iterate over a collection in a foreach loop. You can use foreach to iterate over all C# collection classes, because all C# collection classes inherit from the IEnumerable interface (regular or generic). IEnumerable contains the GetEnumerator method, which returns an enumerator. Occasionally you may find a need to create a …

Continue reading

Permanent link to this article: http://zappmania.in/2012/06/27/c-custom-enumerators-made-simple-with-the-yield-keyword.htm