Back to Devexpress

Remove Discard Variable

coderushforroslyn-401185-refactoring-assistance-remove-discard-variable.md

latest969 B
Original Source

Remove Discard Variable

  • Aug 19, 2021

Removes a discard variable that serves no purpose in code.

Availability

Available when the cursor is in a discard variable.

How to Use

  1. Place the caret in a discard variable (_).

  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

  3. Select Remove Discard Variable from the menu.

After execution, the Refactoring removes the discard variable.

csharp
class RemoveDiscardVariable {
    string GetMethodName(ISymbol symbol) {
        if (symbol is IMethodSymbol) {
            return symbol.Name;
        }
        return null;
    }
}

See Also

Remove Variable with its Initializer

Remove Variable