Is there a way to not create an explicit EventHandler delegate in Visual Studio?

Visual Studio loves to be useful when typing:

Event +=

creating code like:

Event += new EventHandler(EventClassName_Event);

void EventClassName_Event(object sender, EventArgs e)
{
    throw new System.NotImplementedException();
}

Ideally, I would like to remove the explicit delegate and add an explicitly closed one. For instance:

Event += EventClassName_Event;

private void EventClassName_Event(object sender, EventArgs e)
{
    throw new System.NotImplementedException();
}

I looked to see if there was a fragment, but I didn’t find anything. Any suggestions? I have ReSharper, if there is a way he can do this.

+3
source share
1 answer

Using Resharper, if I type:

myObject.SomeEvent += 

then press Ctrl-Shift-Space, I get the opportunity to create a method or delegate (or use an existing method). I think this is what you want.

+2
source

Source: https://habr.com/ru/post/1699553/


All Articles