Enumerators


The next chapter pertains to enumerators, a topic that is a natural extension of this chapter. Enumerators are typically used to iterate collections, which have been the focus of the last two chapters. Enumerators are implemented and typically exposed from an enumerable object. Enumerable objects implement the IEnumerable interface. The IEnumerable.GetEnumerator method returns an enumerator object.

The foreach statement is the most visible expression of enumeration in a C# program. 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.




Programming Microsoft Visual C# 2005(c) The Language
Microsoft Visual Basic 2005 BASICS
ISBN: 0619267208
EAN: 2147483647
Year: 2007
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net