What is the need for Iterator Pattern in C#?Iterator
pattern is used to iterate over a set of elements irrespective of their
internal representation. The elements will be iterated in sequential order.
Here is the sample interface of an iterator: public interface
sampleIterator { firstElement()
Returns the first element of the iterator Usage of iterator pattern has few consequences. They are listed below: The
methods firstElement, nextElement and currentElement will be returning
Object rather than more specific type. You have to explicitly cast the
resultant Object to the corresponding type.
|