Possible Duplicate:
What are ‘closures’ in .NET?
I am currently looking at lambda expression and the word closure keeps coming. Can someone explain it to me in real simple language.
Possible Duplicate:
What are ‘closures’ in .NET?
I am currently looking at lambda expression and the word closure keeps coming. Can someone explain it to me in real simple language.
If the 5 year old knew C#, I would explain with this code sample:
If the 5 year old was learning linq, I would explain with this code sample:
When you know how to do something in general, you can specify some (or all) details and get a closure.
For example, you know how to buy ice-cream. Yyou know what to do if you will be in front of any shop. But if you want to go to a particular shop (for example, due to a Sunday discount), you move out of house with the aim of buying ice-cream there. "Buy some ice-cream at a store on the corner" is a closure of "buy some ice-cream". In fact, all these are closures of "buy some ice-cream somewhere":
Now go play with your friends, son! (and I bear in mind not say anything like that in front of the children)
This is a simple approach to the idea in C#: Closure