[solved] c# question about Enumerator.Current

I’m trying to implement my own IEnumerator but there is a line I don’t understand:
what is the reason for: “object IEnumerator.Current”?

public abstract class buttonEnumerator : IEnumerator<SaveFile>
{
    int position;

    public SaveFile Current => throw new System.NotImplementedException();

    object IEnumerator.Current => Current; //don't understand this line

    public void Dispose()
    {
        throw new System.NotImplementedException();
    }

    public bool MoveNext() //move to next element
    {
        throw new System.NotImplementedException();
    }

    public void Reset()
    {
        position = 0;
    }
}

I believe that is because IEnumerator inherits from IEnumetator, which in its interface has object Current, and the generic Current doesn’t satisfy the interface so you have to implement both.

yeah, makes sense, thank you! Now I got this off my mind :slight_smile: