If I have a method like this:
Foo(params string[] parameters)
I would like to pass in both "regular parameters" and an array in a single call like this:
string[] myArray = new[] { "param3", "param4" };
Foo("param1", "param2", myArray);
such that it is equivalent to this:
Foo("param1", "param2", "param3", "param4");
Is there a function I can call on the array or some sort of way that I can modify my Foo
method? Currently I'm doing something like this:
string[] myArray = new[] { "param3", "param4" };
List<string> arguments = new List<string>
{
"param1",
"param2"
};
arguments.AddRange(myArray);
Foo(arguments.ToArray());
but I'm wondering if there's a better way