[已关闭问题]
<P>using System;<BR>using System.Collections;<BR>using System.Collections.Generic;<BR>public class Stack<T> : IEnumerable<T><BR>{<BR> //数组,索引<BR> T[] items;<BR> int idx;<BR> public Stack()<BR> {<BR> idx = 0;<BR> items = new T[10];</P>
<P> }<BR> public void Push(T t)<BR> {<BR> items[idx++] = t;<BR> }<BR> public T Pop()<BR> { <BR> return items[--idx];<BR> }</P>
<P><BR> public IEnumerator<T> GetEnumerator()<BR> {<BR> for (int i = items.Length - 1; i >= 0; --i)<BR> {<BR> yield return items[i];<BR> }<BR> }</P>
<P>}<BR>class App<BR>{<BR> static void Main()<BR> {<BR> Stack<int> stack = new Stack<int>();<BR> stack.Push(100);<BR> stack.Push(101);<BR> stack.Push(103);<BR> stack.Push(104);<BR> stack.Push(105);<BR> stack.Push(106);<BR> stack.Push(107);<BR> stack.Push(108);<BR> stack.Push(109);<BR> stack.Push(110);<BR> stack.Push(111);<BR> stack.Push(112);<BR> foreach (int i in stack)<BR> {<BR> Console.WriteLine(i.ToString());<BR> }<BR> Console.Read();</P>
<P> }<BR>}提示错误:<FONT face=Verdana>错误 1 “Stack<T>”不会实现接口成员“System.Collections.IEnumerable.GetEnumerator()”。“Stack<T>.GetEn