coderushforroslyn-401182-refactoring-assistance-remove-variable.md
Removes a variable that is never used in code.
Available when the cursor is in an unused variable.
Place the caret in an unused variable. For example, in the “methodSymbol” variable.
Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
Select Unused Local -> Remove ‘xxx’ Variable from the menu.
After execution, the Refactoring removes the unused variable.
public class RemoveUnusedVariable {
string GetMethodName(ISymbol symbol) {
if (symbol is IMethodSymbol) {
return symbol.Name;
}
return null;
}
}
Public Class RemoveVariable
Private Function FormatString(ByVal temperature As Decimal) As String
Dim s As String = String.Format("the temperature is {0}", temperature)
Return s
End Function
End Class
See Also