Chapter 8. Enumerators

Arrays and collections were introduced in Chapter 5—both of these are collection types. Collections group related types, even if the types are related only through inheritance from System.Object. You could maintain a dynamic array of Employee types, which would include instances of HourlyEmployee, ExemptEmployee, and CommissionedEmployee types. You could have a queue of bank requests, such as DepositTransaction, WithdrawalTransaction, and InterestTransaction objects. The relationship of these classes is defined by inheritance at compile time, which allows polymorphism at run time. Enumerating such collections of related objects is a frequent and valuable behavior in many applications.

Enumeration is the process of iterating ...

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.