Chapter 19
Enumerating collections
After completing this chapter, you will be able to:
Manually define an enumerator that you can use to iterate over the elements in a collection.
Implement an enumerator automatically by creating an iterator.
Provide additional iterators that can step through the elements of a collection in different sequences.
Chapter 10, “Using arrays,” and Chapter 18, “Using collections,” showed how to use arrays and collection classes to hold sequences or sets of data. Chapter 10 also detailed the foreach
statement, which you can use to step through, or iterate over, the elements in a collection. In those chapters, you used the foreach
statement as a quick and convenient way of accessing the contents of an array or a collection, ...
Get Microsoft Visual C# Step by Step, 10th Edition 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.