如何在下面的情況下重置IEnumerator實例? (e.Reset()拋出NotImplementedException)如何在以下情況下重置IEnumerator實例
void Main()
{
IEnumerator<string> e = new List<string> { "a", "b", "c" }.Select(o => o).GetEnumerator();
while(e.MoveNext())
{
Console.WriteLine(e.Current);
}
if(
//some condition
)
{
e.Reset();
while(e.MoveNext())
{
//Do something else with e.Current
}
}
}
此外:[爲什麼Enumerator類的Reset()方法必須拋出NotSupportedException()?](http://stackoverflow.com/questions/1468170/why-the-reset-method-on-enumerator-類必須拋出-A-NotSupportedException異常) – sloth 2013-03-01 10:20:36