标题:新手上路,看以下错误怎么解决
只看楼主
Time_Net
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-2-13
 问题点数:0 回复次数:0 
新手上路,看以下错误怎么解决

public class Stack<T> : IEnumerable<T>
{
public void Push(T item)
{
if (items == null)
{
items = new T[4];
}
else if (items.Length == count)
{
T[] newItems = new T[count * 2];
Array.Copy(items, 0, newItems, 0, count);
items = newItems;
}
items[count++] = item;

}
public T Pop()
{
T result = items[--count];
//items[count] =T.default;
return result;


}
public IEnumerator<T> GetEnumerator()
{
for(int i = count - 1; i >= 0; --i)
{
yield return items[i];
}
}

//public Stack()
//{
// items = new T[10];
// count = 0;
//}

public T[] items;
public int count=0;

}

提示错误:

Error 1 'WindowsApplication2.Stack<T>' does not implement interface member 'System.Collections.IEnumerable.GetEnumerator()'. 'WindowsApplication2.Stack<T>.GetEnumerator()' is either static, not public, or has the wrong return type. E:\WebSites\WindowsApplication2\WindowsApplication2\Form1.cs 126 18 WindowsApplication2

搜索更多相关主题的帖子: 新手上路 public null 
2006-02-13 13:41



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-45369-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013087 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved