The requested page is not available for the requested platform. You are viewing the content for Default platform.

Remove Redundant Delegate Creation (C#)

Removes a delegate object initialization expression under the cursor, and inserts the appropriate method reference instead.

Availability

Available from the context menu or via shortcuts:

  • when the cursor is in the right part of a delegate object initialization expression.

Examples

private void TestMethod()
{
    MyHandler += new EventHandler(MyMethod);
}
private System.EventHandler MyHandler;
private void MyMethod(Object sender, EventArgs e)
{

}

Result:

private void TestMethod()
{
    MyHandler += MyMethod;
}
private System.EventHandler MyHandler;
private void MyMethod(Object sender, EventArgs e)
{

}

Screenshot

rsRemoveRedundantDelegateCreation