IEnumerable & IEnumerator
class MyClass:IEnumerator,IEnumerable
{
int[] dates;
int ipoint;
public MyClass()
{
dates =new int[] {1,2,4,3,6,5,7,8,9,0,9};
ipoint = 0;
}
#region IEnumerator 成员
public object Current
{
get { return dates[ipoint]; }
}
public bool MoveNext()
{
ipoint++;
if (ipoint==10)
{
return false;
}
return true;
}
public void Reset()
{
ipoint = 0;
}
#endregion
#region IEnumerable 成员
public IEnumerator GetEnumerator()
{
return this;
}
#endregion
}
-------------------------------------------------
!!!作者:木由水 http://www.cnblogs.com/muyoushui