I have a method that takes this parameter
params string[] additionalParameters
I am building it like this:
qsParams = new string[] {"k=" + k, "l=" + l, "o=" + o, "s=" + s, "t=" + t, "h=" + h, "exp=" + exp };
These are url params. The problem is I only want to add parameters where the variables are not null or empty.
I can do this kind of thing:
if (string.IsNullOrEmpty(k))
{
qsParams = new string[] {"l=" + l, "o=" + o, "s=" + s, "t=" + t, "h=" + h, "exp=" + exp };
}
But that's going to get complicated and ugly trying to handle all the different permutations of empty variables.
Can anyone suggest a simple way to add the params if there are not null? Perhaps a list that I can convert to a params []string?