Remove Unused Parameter

Removes an unused parameter from a method.

Remove Unused Parameter is a cascading refactoring. That is, the refactoring affects all method calls and method declarations in interfaces, base and descendant classes. For instance, if you apply the refactoring to the method declaration within an interface, it also changes the appropriate method declarations in all implementors and all calls to these methods.

Availability

From the context menu or via shortcuts:

  • when the edit cursor or caret is on a method declaration or call, provided that the method contains unused parameters.
Note

The refactoring is available for method declarations in interfaces, base and descendant classes as well as for the declaration in the current class.

Example

private string TestMethod(string param1, int param2)
{
    return String.Format("param2 vale is {0}", param2);
}
private void MyMethod()
{
    string str = TestMethod("My string", 10);
}
Private Function TestMethod(ByVal param1 As String, ByVal param2 As Integer) As String
    Return String.Format("param2 vale is {0}", param2)
End Function
Private Sub MyMethod()
    Dim str As String = TestMethod("My string", 10)
End Sub

Result:

private string TestMethod(int param2)
{
    return String.Format("param2 vale is {0}", param2);
}
private void MyMethod()
{
    string str = TestMethod(10);
}
Private Function TestMethod(ByVal param2 As Integer) As String
    Return String.Format("param2 vale is {0}", param2)
End Function
Private Sub MyMethod()
    Dim str As String = TestMethod(10)
End Sub

Animation

rsRemoveUnusedParameterCSharp

See Also