Why does foreach on arrays and strings get lowered into a while loop that ignores IEnumerable, even though both classes implement it?

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/csharp

Our great sponsors
  • Scout APM - Less time debugging, more time building
  • SonarQube - Static code analysis for 29 languages.
  • SaaSHub - Software Alternatives and Reviews
  • Roslyn

    The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.

    Honestly, I don't have a clue why these would be different. I found the relevant Roslyn code here. You can see on line 719 that this is definitely intentional:

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts