Need a little help understanding IEnumrable and IEnumerable interface implementaion

  class Option<T> : IEnumerable<T>
    {
        private IEnumerable<T> Content { get; }

        private Option(IEnumerable<T> content)
        {
            this.Content = content;
        }

        public static Option<T> Some(T value) => new Option<T>(new[] {value});

        public static Option<T> None() => new Option<T>(new T[0]);

        public IEnumerator<T> GetEnumerator() => this.Content.GetEnumerator(); //Need explaination

        IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();//Need explaination
    }

In the above code Option class implements IEnumerable. Therefore it must also implement IEnumerator. As per my understanding It is supposed to implement methods such as
MoveNext() , Reset() and Current{get;}
But here we have :slight_smile:
public IEnumerator GetEnumerator() => this.Content.GetEnumerator(); //Need explaination
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();//Need explaination
What does this.Content.GetEnumerator(); and this.GetEnumerator(); do here?

.NET Foundation Website | Blog | Projects | Code of Conduct