J
John Kraft
I recently installed Resharper to give it a try, and it has made me
wonder about a few things. The most curious of which concerns event
handlers. Every single example I've ever seen, every line of real
code I've ever seen, and every demo I've ever seen follows the same
patters.
SomeEvent += new EventHandler(EventHandlerMethod);
....
private void EventHandlerMethod(object sender, EventArgs e)
{
...
}
Resharper has been suggesting that the 'new EventHandler()' is
unnecessary code. When I tell it to do it's thing, it changes the
line of code to
SomeEvent += EventHandlerMethod;
I've since been using the latter form to keep Resharper happy, and
because it looks cleaner.
My questions are, is this acceptable? Is this going to cause some
kind of problem or strangeness that I'm not aware of? If there are no
problems with this form, why does Everyone use the new EventHandler
form?
Thanks,
John
wonder about a few things. The most curious of which concerns event
handlers. Every single example I've ever seen, every line of real
code I've ever seen, and every demo I've ever seen follows the same
patters.
SomeEvent += new EventHandler(EventHandlerMethod);
....
private void EventHandlerMethod(object sender, EventArgs e)
{
...
}
Resharper has been suggesting that the 'new EventHandler()' is
unnecessary code. When I tell it to do it's thing, it changes the
line of code to
SomeEvent += EventHandlerMethod;
I've since been using the latter form to keep Resharper happy, and
because it looks cleaner.
My questions are, is this acceptable? Is this going to cause some
kind of problem or strangeness that I'm not aware of? If there are no
problems with this form, why does Everyone use the new EventHandler
form?
Thanks,
John