Chris said:
For example:
void MyMethod(int required, int optional)
{
}
void MyMethod(int required)
{
MyMethod(required, 0 /* put correct default value here */);
}
I would say that the reply from "pedrito" is more suitable in what one
would consider a "variable parameter list". That is, it's not so much
that a given parameter is optional as it is that you don't even know in
advance what the parameters would be (eg similar to the CRT printf()
function).
Exacto!
I would stick to overloading rather than the more complicated variable
parameter list unless you really need the general-purpose behavior that
the "params object[]" technique provides.