I'm trying to go trough this tutorial and there's related code to it. This part
IEnumerator IEnumerable.GetEnumerator()
{
return Items.GetEnumerator();
}
gives me an error
"Using the generic type 'System.Collections.Generic.IEnumerator<T>' requires 1 type arguments"
Could you please tell me what is wrong? Thanks.
You don't inherit from IEnumerable. That is an interface. You can implement interfaces.
The error message you show leads me to suspect that you are implementing IEnumerable.GetEnumerator()
which returns IEnumerator
(a non-generic interface) but attempting to use the generic, IEnumerator<T>
interface in your code.
The code in your link indeed shows the implementation of a generic interface
public IEnumerator <T> GetEnumerator()
{
return Items.GetEnumerator();
}