Skip to content

Iterator pattern StackOverflowException #17

@intvalentin

Description

@intvalentin

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions