Reputation: 129
When declaring variables of the same type, we normally do this:
int a,b,c,d;
Is there a construct to do something similar with function parameters? This function would take 3 integers:
void foo(int a,b,c)
{
}
Upvotes: 3
Views: 61
Reputation: 726609
No, there is no such construct for declaring method arguments. You must declare your parameters one by one.
The closest thing that lets your method receive multiple parameters declared as a single array parameter is params
:
void Foo(params int[] a) {
...
}
This method can be called as follows:
Foo(a, b, c, d);
The caller can pass any number of separate parameters, including zero. Your method would receive all of them in a single array.
Upvotes: 5
Reputation: 9116
No, there's not. This is the documentation about arguments:
https://msdn.microsoft.com/en-us/library/aa691335(v=vs.71).aspx
Upvotes: 1