Is there a “HasNext” method for an IEnumerator?
With Java Iterator s, I have used the hasNext method to determine whether an iteration has more elements (without consuming an element) -- thus, hasNext is like a " Peek " method. My question: is there anything like a " hasNext " or " Peek " method with C#'s generic IEnumerator s? No, unfortunately there isn't. The IEnumerator<T> interface only exposes the following members: Methods: Dispose MoveNext Reset Properties : Current No, but in C# you can repeatedly ask for the current element without moving to the next one. It's just a different way of looking at it. It wouldn't be too hard to write