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

Remove Redundant Delegate Creation

Purpose

Removes a delegate object initialization expression under the cursor, and inserts the appropriate method reference instead. In most cases, the explicit delegate creation is redundant and can be removed, which may improve readability.

Availability

Available when the cursor is on a delegate object creation expression.

Usage

  1. Place the caret on a new delegate creation.

    Note

    The blinking cursor shows the caret's position at which the Refactoring is available.

    textBox1.TextChanged += new EventHandler(ProcessText);
    
  2. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
  3. Select Remove Redundant Delegate Creation from the menu.

After execution, Refactoring replaces the delegate object initializer with the appropriate method reference.

textBox1.TextChanged += ProcessText;
See Also