Code inspection: Unused parameter (private accessibility)
This inspection reports parameters that are declared in a method signature but never used in the method body.
The presence of an unused parameter can be misleading to other developers. It could also be indicative of an error where the parameter was intended to be used, but was inadvertently overlooked, possibly leading to unexpected behavior or bugs in the application.
In the below example, the users of the PrintString
method would probably not check its implementation because its name and signature seem self-explanatory — they would expect it to print the string passed by the argument. So the fact that the method will print a constant string might be an unexpected behavior.
public void PrintString(string str)
{
Console.WriteLine("Hello world");
}
Last modified: 29 May 2024