Skip to main content
A newer version of this page is available. .

Remove Unused Parameter

  • 2 minutes to read

Purpose

Removes the method parameter, which is never referenced in the method body code.

NOTE

Remove Unused Parameter is a cascading Refactoring. That means that the Refactoring affects all method calls and method declarations in interfaces, base and descendant classes.

Availability

Available in the following cases:

  • When the cursor is on a method parameter, assuming this parameter was never used.
  • When the cursor is on a method name, assuming this method has one or more parameters that were never used.

Usage

  1. Place the caret on an unused method parameter.

    NOTE

    The blinking cursor shows the caret's position at which the Refactoring is available.

    static void Main(string[] args) {
        Console.WriteLine("Hello World !!!");
        Console.ReadKey();
    }
    
  2. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
  3. Select Remove Unused Parameter: <parameter name> from the menu.

After execution, the Refactoring removes the unused parameter from the method signature.

static void Main() {
    Console.WriteLine("Hello World !!!");
    Console.ReadKey();
}
See Also