Enumerators

Chapter 8, discusses enumerators, a topic that is a natural extension of this chapter. Enumerators typically are used to iterate collections. Enumerators are implemented and typically exposed by an enumerable object. Enumerable objects implement the IEnumerable interface, where the IEnumerable.GetEnumerator method returns an enumerator object.

The foreach statement is the best known expression of enumeration in C#. The target of the foreach statement is not any object—it has to be an enumerable object.

The next chapter documents the enumerator pattern, including how to implement an enumerator and enumerable object.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.71.21