November 2019
Beginner to intermediate
674 pages
15h
English
If we want to add iterator support to a data structure, we have to implement a public method called GetEnumerator. This method must return either a class, interface, or a record. Let's call this returned value an enumerator.
The enumerator must implement one function and one property. Both must be declared public. The function must be named MoveNext and it must return a boolean result. The for..in loop uses this method to move to the next element in the container and to check whether there are more elements in the container.
The enumerator property must be called Current and it must return the current element in the container (however, the enumerator defines what current is). Usually it is implemented by calling ...
Read now
Unlock full access