Use 'params int[]' : params « Language Basics « C# / CSharp Tutorial






using System;

class MainClass
{
   static void Main() {
      int first = 5, second = 6, third = 7;

      ListInts(first, second, third);

      Console.WriteLine("{0}, {1}, {2}", first, second, third);
   }
   public static void ListInts(params int[] inVals)
   {
      for (int i = 0; i < inVals.Length; i++)        
      {
         inVals[i] = inVals[i] * 10;
         Console.WriteLine("{0} ", inVals[i]);       
      }
   }
   
}
50
60
70
5, 6, 7








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