I am trying to mix optional parameters and variable length parameters (using params keyword):
Here's the function declaration:
void foo(int req, string opt = "empty", params object[] rest) {}
And here are the calls to that function:
foo(1);
foo(1, "something");
foo(1, "something", 2, 3);
foo(1, 2, 3);
The last call does not compile since parameters are provided after the omitted optional parameter. (at least I think that's why it does not work)
How can I omit the optional parameter (opt) and still be able to use the variable length parameter (rest) ?
EDIT: in fact, answer to C# 4.0, optional parameters and params do not work together does not satisfy me because of the possible many combinations of overloads in case of multiple optional parameters.