top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Does C# support variable argument on method?

+3 votes
Does C# support variable argument on method?
posted Dec 9, 2013 by Atul Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Yes. The classic example would be the params object[] args:

//Allows to pass in any number and types of parameters
public static void Program(params object[] args)


void Program(string param1, int param2, params double[] otherParams)

1. They must all be the same type (or of a child type) as is true for arrays as well
2. Only one params keyword is permitted per method
3. It has to be the last parameter.

answer Feb 1, 2014 by Jai Prakash
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.