What is the params keyword?
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
What is the params keyword?
Rating:
The params keyword provides the facility to specify a method parameter that takes a variable number of arguments. The number of arguments can vary. The following code snippet displays the use of the params keyword:
using System;
public class ParamTest
{
public static void Main()
{
ParamFunc(1,2,3);
ParamFunc(1,2,3,4,5);
ParamFunc(1,2,3,4,5,6,7);
}
public void ParamFunc(params int[] arrlist)
{
foreach(int list in arrlist)
Console.WriteLine(list);
}
}
Rating:
Was this information helpful?
Other articles
- How to draw an icon on picture box control in a Windows application?
- What is cryptanalysis?
- Installing a Windows Service Application
- Building Graphical User Interface
- What are the characters that match location in a string?