Parameters are part of the method signature and its
identity.
Implementing a method from an interface, a base class, or a partial method and changing one of its parameters' names will confuse and impact the
method’s readability.
interface IBankAccount
{
void AddMoney(int money);
}
class BankAccount : IBankAccount
{
void AddMoney(int amount) // Noncompliant: parameter's name differs from base
{
// ...
}
}
To avoid any ambiguity in the code, a parameter’s name should match the initial declaration, whether its initial declaration is from an interface,
a base class, or a partial method.
interface IBankAccount
{
void AddMoney(int money);
}
class BankAccount : IBankAccount
{
void AddMoney(int money) // Compliant: parameter's name match base name
{
// ...
}
}
Exceptions
The rule is ignored if both the parameter defined in the initial decalaration is a generic type and the implementing member’s declaration is a
non-generic type.
This allows the implementing member to be more specific and provide more information.