Use 'params int[]' : Params : Language Basics C# Examples


C# Examples » Language Basics » Params »

 

Use 'params int[]'









    
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]);              
            }
      }
      
}
    
   
  
   



Output

50
60
70
5, 6, 7


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Params