O'Reilly logo

Design Patterns in C# by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 28. Iterator

The intent of the ITERATOR pattern is to provide a way to access the elements of a collection sequentially. You might think that in C# there is little to explore in this topic, because the C# language and the .NET FCL build in support for iteration. However, if you extend a codebase by adding a new type of collection, you may find that you need to extend your extension by adding an iterator. This chapter examines the particular case of iterating over a composite. In addition to iterating over new types of collections, the topic of iterating in a multi-threaded environment brings up a number of interesting problems that warrant review. Iteration is not a completely solved problem, even though iteration in C# ordinarily works ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required