The easiest way to ask this question would be to show you all through an example – so here I go!
private void exampleVoid(string someString, params string[] someArray_string)
{
// Do some dirty work
for(int i = 0; i < someArray_string.length; i++)
{
Console.WriteLine(someArray_string[i]);
}
// Recall the routine
exampleVoid("some string", someArray_string)
}
When I re-pass the array at the bottom of the routine, the data is not properly going through. The length of the array is now 0.
Why is that?
I’m not seeing that behavior at all using the following example:
How are you determining that
someArray_stringis empty after the first recursive call? Are you using the debugger? Where are you calling this function and what arguments are you passing into it? Are you actually passing strings as the second…last arguments, i.e., are you passing more than one argument to the method?Also, you will eventually just crash with a
StackOverflowExceptionbecause you never return from the function aside from calling it recursively. The calls never stop, could that possibly be the cause of what you assume to be another problem entirely?