If you drop the overload, then this:
Filter(null);
will be called as this:
string[] valuesOrdered = null;
Filter(valuesOrdered);
and not like this:
Filter(new string[] { null });
So, you can detect this, and if you want it to behave as though you passed an array containing a single null
, then this will suffice:
public List<Item> Filter(params String[] valuesOrdered)
{
valuesOrdered = valuesOrdered ?? new string[] { null };
//...
}
Note that this:
Filter();
will in fact be called as this:
Filter(new string[0]);
so there is a difference between the two that you can detect.
Here's a simple LINQPad program that demonstrates:
void Main()
{
Filter();
Filter(new[] { "a" });
Filter("a");
Filter(null);
}
public static void Filter(params string[] values)
{
values.Dump();
}
output: