C# - Why implement two version of Current when realizing IEnumberable Interface?
<p>I assume the following sample gives a best practice that we should follow when we implement the IEnumberable interface.</p>

<p><a href="http://msdn.microsoft.com/en-us/library/system.collections.ienumerator.movenext.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.collections.ienumerator.movenext.aspx</a></p>

<p>Here is the question:</p>

<ol>
<li>Why should we provide two version of <strong>Current</strong> method?</li>
<li>When the version ONE (object IEnumerator.Current) is used?</li>
<li>When the version TWO (public Person Current ) is used?</li>
<li>How to use PeopleEnum in the foreach statement. // updated</li>
</ol>

<p>Thank you</p>

<pre><code>public class PeopleEnum : IEnumerator
{
    public Person[] _people;

    // Enumerators are positioned before the first element
    // until the first MoveNext() call.
    int position = -1;

    public PeopleEnum(Person[] list)
    {
        _people = list;
    }

    public bool MoveNext()
    {
        position++;
        return (position &lt; _people.Length);
    }

    public void Reset()
    {
        position = -1;
    }

    // explicit interface implementation
    object IEnumerator.Current /// **version ONE**
    {
        get
        {
            return Current;
        }
    }

    public Person Current     /// **version TWO**
    {
        get
        {
            try
            {
                return _people[position];
            }
            catch (IndexOutOfRangeException)
            {
                throw new InvalidOperationException();
            }
        }
    }
}
</code></pre>
