Back to Devexpress

Remove Redundant Delegate Creation

coderushforroslyn-115652-refactoring-assistance-remove-redundant-delegate-creation.md

latest1.1 KB
Original Source

Remove Redundant Delegate Creation

  • Aug 03, 2020

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.

  2. Press 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.

csharp
textBox1.TextChanged += ProcessText;

See Also

Remove Redundant Constructor

Remove Redundant Assignment

Remove Unused Member