class myyield<T> : IEnumerator,IEnumerable
{
List<T> items = null;
int currindex = -1;
public myyield(List<T> list)
{
this.items = list;
}
public Object Current
{
get
{
return items[currindex];
}
}
public bool MoveNext()
{
currindex++;
if (items.Count > currindex)
{
return true;
}
return false;
}
public void Reset()
{
currindex = 0;
}
public IEnumerator GetEnumerator()
{
return this;
}
}
实现IEnumerator接口的枚举器类型
最新推荐文章于 2023-04-03 21:12:50 发布