How yield works in c#

This question already has an answer here:

  • yield statement implementation 3 answers

  • The yield return statement is semantically equivalent to a return statement (which passes control flow to the calling method), followed by a "goto" to the yield statement in the next iteration of the foreach loop.

    Return
    Goto
    

    This behavior does not exist in the Common Language Runtime. It is implemented by a class generated by the C# compiler. This is then executed and JIT-compiled by the CLR. Yield is a form of syntactic sugar.

    链接地址: http://www.djcxy.com/p/54310.html

    上一篇: C#:如何翻译收益关键字

    下一篇: 产量如何在C#中工作