Problem with delegates in C#

后端 未结 4 1011
慢半拍i
慢半拍i 2021-02-06 08:29

In the following program, DummyMethod always print 5. But if we use the commented code instead, we get different values (i.e. 1, 2, 3, 4). Can anybody please explain why this is

4条回答
  •  独厮守ぢ
    2021-02-06 09:29

    This article will probably help you understand what is happening (i.e. what a closure is): http://blogs.msdn.com/oldnewthing/archive/2006/08/02/686456.aspx

提交回复
热议问题