1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4 
5 using System;
6 using System.Runtime.InteropServices;
7 
8 namespace System.Collections
9 {
10     // Base interface for all enumerators, providing a simple approach
11     // to iterating over a collection.
12     public interface IEnumerator
13     {
14         // Advances the enumerator to the next element of the enumeration and
15         // returns a boolean indicating whether an element is available. Upon
16         // creation, an enumerator is conceptually positioned before the first
17         // element of the enumeration, and the first call to MoveNext
18         // brings the first element of the enumeration into view.
19         //
MoveNext()20         bool MoveNext();
21 
22         // Returns the current element of the enumeration. The returned value is
23         // undefined before the first call to MoveNext and following a
24         // call to MoveNext that returned false. Multiple calls to
25         // GetCurrent with no intervening calls to MoveNext
26         // will return the same object.
27         //
28         Object Current
29         {
30             get;
31         }
32 
33         // Resets the enumerator to the beginning of the enumeration, starting over.
34         // The preferred behavior for Reset is to return the exact same enumeration.
35         // This means if you modify the underlying collection then call Reset, your
36         // IEnumerator will be invalid, just as it would have been if you had called
37         // MoveNext or Current.
38         //
Reset()39         void Reset();
40     }
41 }
42