Array As Actual Param : Params : Language Basics C# Examples


C# Examples » Language Basics » Params »

 

Array As Actual Param









    
using  System;

class  MainClass  {
      public  static  void  ListInts(params  int[]  inVals)
      {
            if  (inVals  !=  null)
                  for  (int  i  =  0;  i  <  inVals.Length;  i++)      
                        inVals[i]  =  inVals[i]  *  10;
      }

      static  void  Main()
      {
            int[]  MyArr  =  new  int[]  {  5,  6,  7  };                  

            ListInts(MyArr);                                                    

            foreach  (int  x  in  MyArr)
                  Console.WriteLine("{0}",  x);                            
      }
}
    
   
  
   



Output

50
60
70


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Params