C H A P T E R  18

Enumerators and Iterators

Enumerators and Enumerable Types

In Chapter 12, you saw that you can use a foreach statement to cycle through the elements of an array. In this chapter, you’ll take a closer look at arrays and see why they can be processed by foreach statements. You’ll also look at how you can add this capability to your own user-defined classes, using iterators.

Using the foreach Statement

When you use a foreach statement with an array, the statement presents you with each ...

Get Illustrated C# 2012 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.