I have written a method with these parameters:
Sub MethodName(ByVal paramName1 As String,
ByVal paramName2 As String,
ByVal paramName3 As String,
ByVal ParamArray lastParam As String())
End Sub
In the code above, the name of the parametes are just an example, In my real code, the name of the parameters are descriptive names that I will remark using named parameters to also write comprehensible coding, so following the example method above I will write something like this:
MethodName(paramName1:="...",
paramName2:="...",
paramName3:="...",
lastParam:={"...", "..."})
However, that will fail with a compiler error saying that Named arguments cannot match ParamArray parameters, but as I have written named arguments for the other params then I cannot let the last parameter without a name in this way below, because then, another compiler error says Named argument expected:
MethodName(paramName1:="...",
paramName2:="...",
paramName3:="...",
{"...", "..."})
I attach this to a design conflict in the language syntax behavior related to Microsoft, because the only way I can see that they let the programmer to solve this scenario are one of these unpretty solutions:
Write a common parameter (an
Optional
parameter) instead aParamArray
.Do not use named arguments for any argument.
Ignore the usage of the last parameter in the code examples above.
Maybe exists another solution that I'm missing to preserve a ParamArray
with named arguments?.