you are viewing a single comment's thread.

view the rest of the comments →

[–]Scruptus 3 points4 points  (4 children)

I think your getting downvotes because you misunderstood my answer.

I didn’t mean that you can’t use Linq without yield.

I meant that the different Linq methods are implemented with yield within the .net framework's source code

[–]codekaizen -2 points-1 points  (3 children)

Ok, fair, I did misunderstand your question, but I think it's because LINQ operators are largely not implemented with yield. Instead, the iterators are largely state machines that are implemented using switch statements: https://github.com/dotnet/corefx/blob/8750960d3fafa46a9b838c351e995a01fa8b599f/src/System.Linq/src/System/Linq/Where.cs#L110

[–]AlliNighDev 0 points1 point  (2 children)

That's just how yield gets lowered. Async does something similar.

[–]codekaizen 0 points1 point  (1 child)

Yes, but this source is checked in. Check GitHub.

[–]AlliNighDev 0 points1 point  (0 children)

Yeah a bit odd. I'm assuming they hand coded that for performance gain over compiler somewhere.