Remove Redundant Delegate Creation
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.
Available when the cursor is on a delegate object creation expression.
Place the caret on a new delegate creation.
The blinking cursor shows the caret’s position at which the Refactoring is available.
textBox1.TextChanged += new EventHandler(ProcessText);
- Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
- Select Remove Redundant Delegate Creation from the menu.
After execution, Refactoring replaces the delegate object initializer with the appropriate method reference.
textBox1.TextChanged += ProcessText;