Lecture overview -- Keyboard shortcut: 'u'  Previous page: The Iterator Design Pattern -- Keyboard shortcut: 'p'  Next page: Iterator blocks and yield return -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 35 : 36
Object-oriented Programming in C#
Collection Classes
Making iterators with yield return

The yield return statement can be used to define iterators (enumerators) in an easy, high-level fashion

/user/normark/oop-csharp-1/sources/c-sharp/collections/collection/naive/simple.csA collection of up to three instance variables of type T - with an iterator.


/user/normark/oop-csharp-1/sources/c-sharp/collections/collection/naive/client.csA sample iteration of the three instance variable collection.


Go to exerciseThe iterator behind a yield
 

/user/normark/oop-csharp-1/sources/c-sharp/sequence/2/Sequence.csThe abstract class IntSequence - Revisited.


/user/normark/oop-csharp-1/sources/c-sharp/sequence/2/Sequence.csThe class IntInterval - Revisited.


/user/normark/oop-csharp-1/sources/c-sharp/sequence/2/Sequence.csThe class IntSingular - Revisited.


/user/normark/oop-csharp-1/sources/c-sharp/sequence/2/Sequence.csThe class IntCompSeq - Revisited.


/user/normark/oop-csharp-1/sources/c-sharp/sequence/2/App.csAn application of the integer sequences.


/user/normark/oop-csharp-1/sources/c-sharp/sequence/2/outputOutput of the integer sequence application program.


 

/user/normark/oop-csharp-1/sources/c-sharp/collections/collection/3/farm.csAnimalfarm - GetGroup with yield return.


/user/normark/oop-csharp-1/sources/c-sharp/collections/collection/3/prog.csA sample client of AnimalFarm.


/user/normark/oop-csharp-1/sources/c-sharp/collections/collection/3/outputProgram output.