C# lambda, local variable value not taken when you think?

后端 未结 5 797
清歌不尽
清歌不尽 2020-12-06 17:37

Suppose we have the following code:

void AFunction()
{

   foreach(AClass i in AClassCollection)
   {
      listOfLamb         


        
5条回答
  •  一个人的身影
    2020-12-06 18:03

    I've been caught by this one as well, as said by Calgary Coder, it is a modified closure. I really had trouble spotting them until I got resharper. Since it is one of the warnings that resharper watches for, I am much better at identifying them as I code.

提交回复
热议问题