Using IEnumerator in C#
C#
2
Posts
2
Posters
0
Views
1
Watching
-
Hi, We can loop through collection using foreach and IEnumerator.Can any body help me when to use foreach and when to use Ienumerator since both will loop through collection and get the result?
foreach
uses theIEnumerator
retrieved fromGetEnumerator()
on an object that implementsIEnumerable
. So,foreach
is usingIEnumerator
internally anyway.
Scottish Developers events: * .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy * Developer Day Scotland: are you interested in speaking or attending? My: Website | Blog