This comes from this other question:
( How to build a method with unspecified amount of params en C# ).
But since it’s a different question I had to ask it here
Supposing you have a method overloaded (this overload is allowed by the compiler):
private static string AddURISlash(params string[] remotePaths) //multiple strings
private static string AddURISlash(string remotePaths) //single string
How should you know which will be executed when only one parameter is recieved?
Is there a convention? or something that you have to test once?
Do I have to assume that since the only way to the single string method to be executed is to recieve a single string, that’s the one that unequivocally be executed?
Thanks
You read the specification, which explains how overload resolution is handled. From section 7.5.3.2, the relevant bullet point is:
So the version which doesn’t require parameter array expansion (your single string version) is chosen at compile-time instead of the parameter array version.