54 lines
809 B
Plaintext
54 lines
809 B
Plaintext
Adding ``++params++`` to a method override has no effect. The compiler accepts it, but the callers won't be able to benefit from the added modifier.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
[source,csharp]
|
|
----
|
|
class Base
|
|
{
|
|
public virtual void Method(int[] numbers)
|
|
{
|
|
...
|
|
}
|
|
}
|
|
class Derived : Base
|
|
{
|
|
public override void Method(params int[] numbers) // Noncompliant, method can't be called with params syntax.
|
|
{
|
|
...
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
[source,csharp]
|
|
----
|
|
class Base
|
|
{
|
|
public virtual void Method(int[] numbers)
|
|
{
|
|
...
|
|
}
|
|
}
|
|
class Derived : Base
|
|
{
|
|
public override void Method(int[] numbers)
|
|
{
|
|
...
|
|
}
|
|
}
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
endif::env-github,rspecator-view[]
|