In a previous post I stated that I thought it would be nice to treat methods as objects. I then found that delegates do just that, in a pointer sort of way...
But in Whidbey, you'll be able to wrap code blocks in anonymous delegate containers and pass them rather than having to create an external delegate and pass the ref. Just cool.
“Current bits” capability - passing delegates as parm...
and now for Whidbey!
The following is an except from this article on MSDN - Sneak Preview of Whidbey
Anonymous methods can be thought of as the ability to pass a code block as a parameter. In general, anonymous methods can be placed anywhere that a delegate is expected. The simplest example is something like:
button1.Click += delegate { MessageBox.Show("Click"); };
There are a few things to notice here. First, it's legal to write a method inline. Second, there is no description of either the return type or the method parameters. Third, the keyword delegate is used to offset this construct. The return type isn't listed because the compiler infers it. That is, the compiler knows what is expected (EventHandler), and then checks to see if the anonymous method defined is convertible to that method.
You may notice that in the previous example there were no parameters listed. This is because they weren't needed within the code block. If these parameters were used, then the declaration would look like this:
button1.Click += delegate(object sender, EventArgs e) { MessageBox.Show(sender.ToString()); };
Notice that both the type and parameter name are given.