相关疑难解决方法(0)

有关IEnumerable.GetEnumerator()的错误消息

我收到此错误消息,我无法弄清楚原因!

Error   1   'Exo5Chap12.ShortCollection<T>' does not implement interface member 
'System.Collections.IEnumerable.GetEnumerator()'. 
'Exo5Chap12.ShortCollection<T>.GetEnumerator()' cannot implement 
'System.Collections.IEnumerable.GetEnumerator()' because it does not have the matching 
return type of 'System.Collections.IEnumerator'.    
E:\MyFolders\Dev\c#\Chapter12\Exo5Chap12\Exo5Chap12\exo5.cs 9   18  Exo5Chap12
Run Code Online (Sandbox Code Playgroud)

以下是具有GetEnumerator()实现的代码.怎么了?

 public class ShortCollection<T> : IList<T>
{
    protected Collection<T> innerCollection;
    protected int maxSize = 10;
    public IEnumerator<T> GetEnumerator()
    {
        return (innerCollection as IEnumerator<T>).GetEnumerator();
    }
}
Run Code Online (Sandbox Code Playgroud)

c# ienumerable

8
推荐指数
2
解决办法
9369
查看次数

标签 统计

c# ×1

ienumerable ×1