Stack Overflow illuminates that:
public static int addTwoEach(params int[] args)
{
return args.Sum() + 2 * args.Length;
}
...may be called like so:
var foo = addTwoEach(1, 2, 3, 4, 5);
...and not just like so:
var foo = addTwoEach(new int[] { 1, 2, 3, 4, 5 });
The second scenario works just fine without the params keyword of course.
No comments:
Post a Comment