我有以下代码,但我期望得到不同的结果。
我期望得到以下结果:100, 110, 120, 200, 500。
我现在想知道这个+1是从哪里来的?这与IT技术有关。
我期望得到以下结果:100, 110, 120, 200, 500。
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApplication11
{
public class Program
{
static void Main(string[] args)
{
var values = new List<int> { 100, 110, 120, 200 , 500 };
// In my mind the result shall be like (100,0) => 100 + 0 = 100
// In my mind the result shall be like (110,0) => 110 + 0 = 110 etc.
var sumLinqFunction = new Func<int, int, int>((x, y) => x + y);
var outputs = values.Select(sumLinqFunction);
foreach (var o in outputs)
Console.WriteLine(o);
}
}
}
控制台输出(真实结果)
100
111
122
203
504
我现在想知道这个+1是从哪里来的?这与IT技术有关。
y
是0
? - SLaks