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
39 views
Does C# support variable argument on method?
posted Dec 9, 2013 by Atul Mishra

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social 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)

or

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

Restrictions:
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
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...