The Params keyword in C# lets the developers to specify parameter for the method that can take variable no. of arguments .
For example
public void Data(params int[] datum) { int val=0; foreach (var da in datum) { val = val + da; } }
In the above sourcecode , the method Data accepts the parameter integer array . since the parameter is marked as params , you could call the function Data with the comma seperated value like below
public void Main() { Data(1, 2, 3); }
Leave a Reply