Unless you use the
params
keyword, you can't have a variable number of parameters anyway - even if you use the defaulting syntax to omit them when you call it, the actual method will always have the same fixed number of parameters.
If you do use
params
:
private void MyMethod(params string[] pars)
{
...
}
Then you can check the number by simply checking the arrays Length property:
private void MyMethod(params string[] pars)
{
if (pars.Length > 0)
{
...
}
}