PreviousNext

Introducing C# 9: Extension GetEnumerator support for foreach loops

by anthonygiretti, 2020-11-02T03:00:34.878Z

As you may know, in order to be able to iterate on a collection in C# with the foreach loop the collection must expose a public method GetEnumerator() which doesn’t exist on IEnumerator and IAsyncEnumerator interfaces. C# 9 allows to create an extension method to allow foreach loops on those interfaces. Let’s see in this article how to proceed.

Read More