Reputation: 110
I have a situation where I want to pass an unknown number of arguments to a function. The function is basically structured as:
public void test(string x, params string[] y)
{
//code
}
I need to pass an unknown number of arguments into the y input. In some cases, I may have 2 y's, in others I could have 20 y's in the format of
test("test", arg[0], arg[1], arg[2], arg[3] ... arg[20]);
Any suggestions on how to enter a varying number of y inputs into the above function? I'm attempting to automate a process and c# is new to me.
Upvotes: 0
Views: 561
Reputation: 247
why you don't use a list, you can add the elements to the list and then send it to your function see that link http://msdn.microsoft.com/en-us/library/6sh2ey19(v=vs.110).aspx
Upvotes: 0