Skip to main content

How to Resolve Error "CS0466:'Class.Method' should not have a params parameter since 'Interface.Method' does not" in C#

The Compiler Error CS0466 is a signature mismatch error that occurs specifically when implementing interfaces. The message reads: "'Class.Method' should not have a params parameter since 'Interface.Method' does not".

This error happens when you use Explicit Interface Implementation and attempt to add the params keyword to the implementation, even though the original interface definition defines the parameter as a standard array. Because explicit implementations are only accessible via the interface itself, adding params to the class implementation is pointless (the caller sees the interface, not the class) and is therefore forbidden.

This guide explains how to align your implementation with the interface contract.

Understanding Explicit Implementation Rules

When you implement an interface explicitly (e.g., void IMyInterface.MyMethod()), you are creating a method that is hidden from the class's public API. It can only be called by casting the object to the interface type.

  • The Contract: The caller sees IMyInterface.
  • The Call: ((IMyInterface)obj).MyMethod(args).

If IMyInterface does not declare params, the compiler does not allow the variable-argument syntax at the call site. Therefore, adding params to the hidden implementation inside the class creates a feature that is logically impossible to use via the interface. C# flags this inconsistency as CS0466.

Scenario: Adding params to Explicit Implementation

You define an interface that expects an array. In your class, you try to be "helpful" by making the explicit implementation accept variable arguments.

Example of error:

public interface ILogger
{
// Interface expects a standard array
void Log(string[] messages);
}

public class SystemLogger : ILogger
{
// ⛔️ Error CS0466: 'SystemLogger.ILogger.Log(params string[])'
// should not have a params parameter since 'ILogger.Log(string[])' does not.
void ILogger.Log(params string[] messages)
{
foreach (var msg in messages) Console.WriteLine(msg);
}
}

Solution 1: Remove params from Implementation

If you cannot change the interface (e.g., it comes from a third-party library), you must make your implementation match the definition exactly. Remove the params keyword.

Solution:

public interface ILogger
{
void Log(string[] messages);
}

public class SystemLogger : ILogger
{
// ✅ Correct: Signature matches the interface exactly.
void ILogger.Log(string[] messages)
{
if (messages != null)
{
foreach (var msg in messages) Console.WriteLine(msg);
}
}
}
note

Callers must now pass an array explicitly: ((ILogger)logger).Log(new[] { "A", "B" });.

Solution 2: Update the Interface Definition

If you own the interface and you want callers to use the params syntax, you should add the keyword to the Interface itself.

Solution: add params to the interface. The implementation (explicit or implicit) must then also include params to match.

public interface ILogger
{
// ✅ Correct: The contract now promises variable arguments.
void Log(params string[] messages);
}

public class SystemLogger : ILogger
{
// ✅ Correct: Implementation matches the new contract.
void ILogger.Log(params string[] messages)
{
foreach (var msg in messages) Console.WriteLine(msg);
}
}

// Usage:
// ILogger log = new SystemLogger();
// log.Log("Message 1", "Message 2"); // params works!

Conclusion

CS0466 enforces signature consistency for hidden interface members.

  1. Check the Interface: Does the interface definition include params?
  2. Match the Signature:
    • If the interface has params, your explicit implementation must have it.
    • If the interface does not have params, your explicit implementation cannot have it.
  3. Decide: Either remove the keyword from your class or add it to the interface definition.