Skip to content

separate class for getting IEnumerator or implementation IEnumerator inside are not needed #1099

@seniorwebdeveloper2

Description

@seniorwebdeveloper2

Making PeopleEnum class is not needed, when you use foreach without custom sort of output. Instead of it just call GetEnumerator() from _people. _people - is array of Person objects. And arrays of any kind of object have GetEnumerator method.
Write public IEnumerator GetEnumerator() in next way:
{
return _people.GetEnumerator();
}
Class PeopleEnumClass is not needed and may be deleted.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions