arrays - c# Pass params from one routine to another -
the easiest way ask question show through example - here go!
private void examplevoid(string somestring, params string[] somearray_string) { // dirty work for(int = 0; < somearray_string.length; i++) { console.writeline(somearray_string[i]); } // recall routine examplevoid("some string", somearray_string) } when re-pass array @ bottom of routine, data not going through. length of array 0.
why that?
i'm not seeing behavior @ using following example:
class program { static void main( string[] args ) { foo( 5, "one", "two", "three" ); console.readline(); } static void foo( int counter, params string[] parms ) { if( counter <= 0 ) return; foreach( var str in parms ) { console.writeline( str ); } foo( --counter, parms ); } } how determining somearray_string empty after first recursive call? using debugger? calling function , arguments passing it? passing strings second...last arguments, i.e., passing more 1 argument method?
also, crash stackoverflowexception because never return function aside calling recursively. calls never stop, possibly cause of assume problem entirely?
Comments
Post a Comment