I have this test code:
void func1(string a, params string[] p)
{
func1(a, true, p);
}
void func1(string a, bool b, params string[] p)
{
//...
}
void func2(string a, bool b = true, params string[] p)
{
//...
}
void exec()
{
func1("a", "p1", "p2");
func2("a", "p1", "p2");
}
Is func1
and func2
equals?
There are no errors when I create the func2
, but, when I try to use the func2
like in exec (using the optional value), the compiler show an error This function has some invalid arguments
.
I think that func1
and func2
are equal for someone that will consume this function like an API.
What is wrong with this code? Can I use this approach for functions that have optional and params values?