A comparison with C# 1 and C# 2.0 should clarify I hope:
* Here's how you "traditionally" connect an eventhandler in C# 1:
myButton.OnClick += new ClickEventHandler(m_clickHandlerMethod);
...
m_clickHandlerMethod(object sender, EventArgs arg)
{
MessageBox.Show("Clicked");
}
----------
* In C# 2.0, with the advent of anonymous methods, you can now write the above like this:
myButton.OnClick += delegate(object sender, EventArgs arg)
{
MessageBox.Show("Clicked");
};
----------
Only the first, "traditional", case above is handled by VS default intellisense. As soon as you write "+=" it suggest the correct "new ClickEventHandler(m_clickHandlerMethod)" code and even offers to create the "m_clickHandlerMethod(object sender, EventArgs arg)" stub.
But, in the C# 2.0 case we sadly don't get any help with generating the argument list. My idea is that as soon as I've written "+= delegate" the appropriate arguments should be offered by VA-intellisense (i.e "delegate(object sender, EventArgs arg) { .. }" ).
- Secondly, it also seems like neither VS nor VA intellisense senses the arguments once I'm writing code inside the anonymous method. In the example above the intellisense doesn't offer to insert "sender" or "arg" when writing "se" or "ar" for example as it would have done in an ordinary method arguments. (If I spell them out fully it will find members inside the argument-objects correctly though).
(See here for examples regarding C# 2.0 delegates etc http://msdn.microsoft.com/en-us/magazine/cc163970.aspx)
Hope the above makes sense. I think this would be a great addition, since nowadays I (and I assume other people too) are using anonoymous methods/delegates (they're actually closures too) more and more.
Regards
// Fredrik