I read this question and read this answer
This is a really fantastic feature. This allows you to close access to something usually hidden, say, a private class variable, and let it control it in a controlled way as a response to something like an event.
You can mimic what you want easily by creating a local copy of the variable and using it.
Do we need to implement Lock () in this situation?
What does it look like?
According to Eric Lippert, the compiler makes the code look like this :
private class Locals
{
public int count;
public void Anonymous()
{
this.count++;
}
}
public Action Counter()
{
Locals locals = new Locals();
locals.count = 0;
Action counter = new Action(locals.Anonymous);
return counter;
}
What will the Lambda look like, as well as the long code?
source
share