dotnet / dotnet/dotnet-api-docs
separate class for getting IEnumerator or implementation IEnumerator inside are not needed
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
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.*
* ID: 87006da9-9d40-cb2e-b516-715ea36cdbea
* Version Independent ID: 5c32a764-8844-e344-a42b-8dd1177fa32f
* Content: [IEnumerable Interface (System.Collections)](https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerable?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev15.query%3FappId%3DDev15IDEF1%26l%3DEN-US%26k%3Dk(System.Collections.IEnumerable);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.7.1);k(DevLang-csharp)%26rd%3Dtrue&view=netframework-4.7.2)
* Content Source: [xml/System.Collections/IEnumerable.xml](https://github.com/dotnet/dotnet-api-docs/blob/master/xml/System.Collections/IEnumerable.xml)
* Product: **dotnet-api**
* GitHub Login: @mairaw
* Microsoft Alias: **mairaw**
Contributor guide
Assessment
This issue has not been assessed yet.