Defining a parameter array using the params keyword allows you to pass a variable number of arguments to a method.
1
| public void PerformCommands( params string [] commands) |
You can pass a variable number of arguments to a method that has a parameter array.
1
| kirby.PerformCommands( "Sit" , "Stay" , "Beg" ); |
You can also just pass an array of the proper type.
1
2
3
| string [] tricks = new string [] { "Roll over" , "Weave" }; kirby.PerformCommands(tricks); |