我有一个实现IEnumerator<string>. 见下文:
public class MyClass : IEnumerator<string>
{
public bool MoveNext()
{
//....
}
//Implement other required methods....
//Confusion lies below:
public string Current { get { return this.CurrentLine; } }
//Why do I need to implement IEnumerator.Current?! In my tests, it's not even called during my iteration
object IEnumerator.Current { get { throw new NotImplementedException(); } }
}
IEnumerator<T>除了接口和IEnumerator接口(继承)上都存在 .Current 属性这一事实之外IEnumerator<T>,实现它的意义何在?如上所示,它甚至没有被调用。