Does C# support a variable number of arguments?
If yes, How does C# support variable no of arguments?
What are the examples?
How are variable arguments useful?
EDIT 1: What are the restrictions on it?
EDIT 2: The Question is not about Optional param But Variable Param
Yes. The classic example wourld be the
params object[] args:A typical usecase would be passing parameters in a command line environment to a program, where you pass them in as strings. The program has then to validate and assign them correctly.
Restrictions:
paramskeyword is permitted per methodEDIT: After I read your edits, I made mine. The part below also covers methods to achieve variable numbers of arguments, but I think you really were looking for the
paramsway.Also one of the more classic ones, is called method overloading. You’ve probably used them already a lot:
Last but not least the most exiting one: Optional Arguments
http://msdn.microsoft.com/en-us/library/dd264739.aspx