Error message regarding IEnumerable.GetEnumerator().

Posted by Bon_chan on Stack Overflow See other posts from Stack Overflow or by Bon_chan
Published on 2010-06-05T18:53:57Z Indexed on 2010/06/05 19:02 UTC
Read the original article Hit count: 118

Filed under:
|
|

I get this error message and I can't figure out why!

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

Here is the code with an implementation of GetEnumerator(). What is wrong?

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about beginner