Use regular parameter with a params parameter. : params « Language Basics « C# / CSharp Tutorial






using System; 
 
class MyClass { 
  public void showArgs(string msg, params int[] nums) { 
    Console.Write(msg + ": "); 
 
    foreach(int i in nums) 
      Console.Write(i + " "); 
 
    Console.WriteLine(); 
  } 
} 
 
class MainClass { 
  public static void Main() { 
    MyClass ob = new MyClass(); 
 
    ob.showArgs("Here are some integers",  
                1, 2, 3, 4, 5); 
 
    ob.showArgs("Here are two more",  
                17, 20); 
 
  } 
}
Here are some integers: 1 2 3 4 5
Here are two more: 17 20








1.16.params
1.16.1.Demonstrate params
1.16.2.Use regular parameter with a params parameter.
1.16.3.Mix params array type with other data types
1.16.4.Array As Actual Param: params int[] inVals
1.16.5.Use 'params int[]'
1.16.6.Sending in args using params keyword: object, int and string