Iterators

Using iterators is an alternative to fully implementing IEnumerator or IEnumerable interfaces. Iterators also provide an easier way to implement complex enumerators, such as reverse enumerators. Previously in this chapter, different implementation strategies for enumerators have been shown. There are several options. The enumerator could be implemented as a nested class. A versioned collection could be used. The implementation could be generic or nongeneric. Why should all developers consider these options and implement their rendition of an enumerator? This would not appear to be a good use of their collective mental prowess. Almost assuredly, the various implementations of the enumerator pattern are within an acceptable delta in performance ...

Get Programming Microsoft® Visual C#® 2008: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.