The "params" keyword for method allows you specify a method
parameter that takes an argument where the number of arguments is variable. No additional parameters are permitted after the "params" keyword in a method declaration, and only one "params" keyword is permitted in a method declaration. |
using System; //method_param.cs public class team { public static void bdale(string a, params object[] list) { Console.WriteLine("team : " + a); for ( int i = 0 ; i < list.Length ; i++ ) Console.Write(list[i]); Console.WriteLine(); } public static void raiders(string b, params object[] list) { Console.WriteLine("team : " +b); for ( int i = 0 ; i < list.Length ; i++ ) Console.Write(list[i]); Console.WriteLine(); } } class test { public static void Main() { team.bdale("bdale","Baba #", 10, " Position Defense"); Console.WriteLine("---------------"); team.raiders("raiders","Jacob #", 7 , " Position Offense"); } } |
while calling you need to call with the class, not with the objects. if
you write like this
|