odd lambda behavior

前端 未结 3 1571
感动是毒
感动是毒 2021-02-20 08:36

I stumbled across this article and found it very interesting, so I ran some tests on my own:

Test One:

List actions = new          


        
3条回答
  •  被撕碎了的回忆
    2021-02-20 08:54

    @Eric Lippert has explained this in great detail in his two-parts article:

    • Closing over the loop variable considered harmful
    • Closing over the loop variable, part two

    It is a must-read article, as it explains the behavior in depth and at implementation-level.

提交回复
热议问题