I have a simple class, MyClass, which already has the Reset(), MoveNext(), and Current pieces. But it doesn't provide an iterator, it just exposes those components.
I started with this:
public IEnumerator<MyClass> GetEnumerator()
{
Reset();
while (MoveNext())
yield return Current;
}
Which triggers the following error:
CS1579 foreach statement cannot operate on variables of type 'IEnumerator' because 'IEnumerator' does not contain a public instance definition for 'GetEnumerator'
I tried a bunch of other approaches, but no joy.
Would someone point me in the right direction?
Thanks!