枚举类型
namespace ConsoleApplication1
{
public class Stack : IEnumerable
{
public int[] items = { 0, 1, 2, 3 };
public IEnumerator GetEnumerator()
{
for (int i = 0; i < items.Length; i++)
yield return items[i];
}
}
class Program
{
static void Main(string[] args)
{
Stack stack=new Stack();
IEnumerator i=stack.GetEnumerator();
while (i.MoveNext())
{
Console.Write(i.Current);
}
Console.Read();
}
}
}