I'm kind of new to C #, I know that the method defined in the interface needs to be implemented
but in the code below I did not implement the MoveNext () method
static void Main()
{
List<int> list = new List<int>();
list.Add(1);
list.Add(5);
list.Add(9);
List<int>.Enumerator e = list.GetEnumerator();
Write(e);
}
static void Write(IEnumerator<int> e)
{
while (e.MoveNext())
{
int value = e.Current;
Console.WriteLine(value);
}
}
I also checked in the metadata and it does not provide any implementation.
so why doesn't the compiler throw any error? where is the MoveNext () method implemented & how does it go to the next value?
Is the code for the MoveNext () method an automatically generated compiler? please, help
source
share