Where is this capture stored in this C# Lambda? -
this question has answer here:
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
Post a Comment