forked from kamranahmedse/design-patterns-for-humans
-
Notifications
You must be signed in to change notification settings - Fork 168
Open
Description
For iterator pattern should be:
public IEnumerator<RadioStation> GetEnumerator()
{
//Use can switch to this internal collection if you do not want to transform
//return mStations.GetEnumerator();
//use this if you want to transform the object before rendering
foreach (var x in mStations)
{
yield return x;
}
}
IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
Currently is wrong and throws StackOverflowException.
public IEnumerator<RadioStation> GetEnumerator()
{
return this.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
//Use can switch to this internal collection if you do not want to transform
//return mStations.GetEnumerator();
//use this if you want to transform the object before rendering
foreach (var x in Stations)
{
yield return x;
}
}
Metadata
Metadata
Assignees
Labels
No labels