Your Func , sumLinqFunction expects two parameters, adds them and returns the result.
When you use this in a Select statement, it looks like this:
var outputs = values.Select((x, y) => x + y);
which uses Select overload, which expects the second parameter to be an index.
The first argument to the selector represents the item to process. The second argument to the selector represents the zero index of this element in the original sequence. This can be useful if the elements are in a known order, and you want to do something with, for example, an element at a specific index. It can also be useful if you want to get the index of one or more elements.
So y starts at 0 . With each iteration, index ( y ) moves on to the next element, so you see +1 increment.
To explain this a bit, you can modify your Func to display the current x and y values, for example:
var sumLinqFunction = new Func<int, int, int>((x, y) => { Console.WriteLine("x: {0} , y: {1}", x, y); return x + y; }); var outputs = values.Select(sumLinqFunction).ToList();
This will give you:
x: 100 , y: 0 x: 110 , y: 1 x: 120 , y: 2 x: 200 , y: 3 x: 500 , y: 4
For your comment:
I need to call select with a default value of 0, not an index!
Then, instead of a Func you can simply do:
int y = 0; var outputs = values.Select(r => r + y);