Use regular parameter with a params parameter. : Params : Language Basics C# Examples


C# Examples » Language Basics » Params »

 

Use regular parameter with a params parameter.









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



Output

Here are some integers: 1 2 3 4 5
Here are two more: 17 20


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Language Basics
» Params