The iterator design pattern is an integrated part in many languages and frameworks. In C# you can implement the IEnumerable interface (defining the GetEnumerator method) to make a class iterable.
Using the yield keyword makes the method return an iterator.
This is so simple in the .NET framework that I did not bother to create a UML diagram this time. Check the code in my GitHub repository for an example on how to implement IEnumerable.
Using the yield keyword makes the method return an iterator.
This is so simple in the .NET framework that I did not bother to create a UML diagram this time. Check the code in my GitHub repository for an example on how to implement IEnumerable.
Kommentarer
Skicka en kommentar