title: IEnumerator: How do I prevent C# compiler errors CS0539 & CS0738?
body: <p>I have encountered a pair of related compiler errors. I am unable to decipher the compiler's error messages. The solution SHOULD BE brain-dead simple.</p>
  <p>Could you please reply with the worked out solution? It should be a single line of code.</p>
  <p>Here's my code, as stripped-down as possible while still exhibiting the error:</p>
  <pre><code>using System;
  using System.Collections.Generic;
  
  public class Bar { }
  
  //---- Foo
  public class Foo : IEnumerator&lt;Bar&gt;
  {
      Bar[] bars;
      private int curIndex;
      private Bar curBar;
  
      public Foo(Bar[] collection) { }
  
      public bool MoveNext() { return true; }
  
      public void Reset() {  }
  
      void IDisposable.Dispose() { }
  
      public Bar Current { get { return curBar; } }
  
      object IEnumerator&lt;Bar&gt;.Current { get { return Current; } }
  } // class Foo
  </code></pre>
  <p>When I attempt to compile that code, I get two compiler errors, as follows:</p>
  <ol>
  <li>CS0539: 'Foo.Current' in explicit interface declaration is not found among members of the interface that can be implemented.</li>
  <li>CS0738   'Foo' does not implement interface member 'IEnumerator.Current'. 'Foo.Current' cannot implement 'IEnumerator.Current' because it does not have the matching return type of 'object'.</li>
  </ol>
  <p>Regarding CS0539, my understanding of the phrase &quot;explicit interface declaration&quot; suggests that the code below is the &quot;explicit interface declaration&quot; that the compiler is insisting does not exist:</p>
  <pre><code>public Bar Current { get { return curBar; } }
  </code></pre>
  <p>Regarding CS0738, when I try to add an interface member IEnumerator.Current that returns an object, the compiler barfs two different error messages:</p>
  <ol>
  <li>CS0305 Using the generic type 'IEnumerator' requires 1 type arguments.</li>
  <li>CS0538 'IEnumerator' in explicit interface declaration is not an interface.</li>
  </ol>
  <p>Therefore, I am trapped in a in a maze of twisty little passages, all alike, offering no escape. I have no idea how to resolve this problem. Hours of Googling have been unproductive.</p>
  <p>P.S.: Why am I implementing an enumerator rather than [whatever]? Because my use-case requires an enumeration of one cycle around a circular collection of values. I had expected to steal... I mean, borrow... I mean, &quot;reuse&quot; an existing CircularEnumerator class, but I could not find one -- or, at least, not one that my tiny little brain could understand. Thanks!  :-)</p>