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? 回答1: No, unfortunately there isn't. The IEnumerator<T> interface only exposes the following members: Methods: Dispose MoveNext Reset Properties : Current 回答2: No, but in C# you can repeatedly ask for the current