2023-05-03 11:06:20 +02:00
== Why is this an issue?
2023-02-02 09:30:33 +01:00
There's no point in creating an array solely for the purpose of passing it to a `ParamArray` parameter. Simply pass the elements directly. They will be consolidated into an array automatically.
2023-05-03 11:06:20 +02:00
=== Noncompliant code example
2023-02-02 09:30:33 +01:00
[source,vbnet]
----
Class SurroundingClass
Public Sub Base()
Method(New String() { "s1", "s2" }) ' Noncompliant: unnecessary
Method(New String(12) {}) ' Compliant
End Sub
Public Sub Method(ParamArray args As String())
' Do something
End Sub
End Class
----
2023-05-03 11:06:20 +02:00
=== Compliant solution
2023-02-02 09:30:33 +01:00
[source,vbnet]
----
Class SurroundingClass
Public Sub Base()
Method("s1", "s2")
Method(New String(12) {})
End Sub
Public Sub Method(ParamArray args As String())
' Do something
End Sub
End Class
----