Where is this capture stored in this C# Lambda? -


all of posts c# lambdas says captures references variables.

but how can this?

private system.action lambda; void start()  {     int = 0;     lambda = () => {         i++;         debug.log(i);      }; } void update() {     lambda(); } 

this print out 1..2...3...etc

my understanding variable allocated on stack, referenced. after start() exits, should destroyed, causing undefined behavior when lambda() called.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -