What is closure in C #?

Duplicate

Closing in .NET

What are short circuits in C #?

+60
closures c #
Feb 27 '09 at 16:29
source share
1 answer

Closing in C # takes the form of a built-in delegate / anonymous method . A closure is attached to its parent method, which means that variables defined in the body of the parent method can be referenced from an anonymous method. There is a great blog post here .

example

public Person FindById(int id) { return this.Find(delegate(Person p) { return (p.Id == id); }); } 

You can also take a look at the blogs of Martin Fowler or John Skeet . I'm sure you can get a deeper breakdown from at least one of them ....

+92
Feb 27 '09 at 16:29
source share



All Articles