Remove Variable with its Initializer
#Purpose
Removes an unused variable with its initializer from code.
#Availability
Available when the cursor is in an initialized variable. This variable is never used in code and can be deleted.
#How to Use
Place the caret in an initialized variable. For example, in the “statementsList” variable.
Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
Select Unused Local -> Remove ‘xxx’ Variable with its Initializer from the menu.
After execution, the Refactoring removes the unused variable with its initializer.
class RemoveVariable {
private BlockSyntax GetGetterBody(IMemberDescriptor field) {
return SyntaxFactory.Block(new StatementSyntax[] { FieldToReturnStatement(field) });
}
}