O'Reilly logo

Expert C# 5.0: with the .NET 4.5 Framework by Mohammad Rahman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 9

images

Foreach and Iterator

This chapter will discuss the foreach statement and iterators block. The foreach statement is used to iterate an array or an object collection that implements the System.Collections.IEnumerable or System.Collections.Generic.IEnumerable<T> interface. The iterators block is also used to iterate through an array or an object collection based on the state machine generated automatically by the C# compiler.

State Machine

Throughout this chapter, you will explore how the C# compiler generates the state machine for an iterator block, what the states are that the state machine contains, and how the state transition takes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required