.NET:有没有"规则hasNext"方法一个IEnumerator?

.NET:有没有"规则hasNext"方法一个IEnumerator?

问题描述:

使用Java的的Iterator S,我已经使用了规则hasNext 方法来确定一个迭代是否有更多的元素(不耗时一个元素) - 因此,规则hasNext 就像是一个皮克的方法。

With Java Iterators, 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.

我的问题:是否有像规则hasNext 皮克的方法什么用C#的通用的IEnumerator S'

My question: is there anything like a "hasNext" or "Peek" method with C#'s generic IEnumerators?

没有,遗憾的ISN吨。

No, unfortunately there isn't.

IEnumerator的< T> 接口只公开以下成员:

The IEnumerator<T> interface only exposes the following members:

方法:

的Dispose

的MoveNext

重置

属性

当前