Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same.
This rule raises an issue when a private method or constructor of a class/struct takes a parameter without using it.
private void DoSomething(int a, int b) // "b" is unused
{
Compute(a);
}
private void DoSomething2(int a) // value of "a" is unused
{
a = 10;
Compute(a);
}
private void DoSomething(int a)
{
Compute(a);
}
private void DoSomething2()
{
var a = 10;
Compute(a);
}
This rule doesn’t raise any issue in the following contexts:
this parameter of extension methods. NotImplementedException. virtual, override methods.