理解这个Lambda表达式

Bix*_*xel 2 c# lambda

在学习教程时发现这一点,无法理解它,因为源代码没有对它正在做什么做出评论.我传递了许多不同的byte []值,看看我是否可以解决它,我不能.大多数Lambda教程只显示单个变量类型 - 而不是2.

using System.Linq;
using System.Numerics;

private string DoLamdaExpression(byte[] data)
{
    var intData = data.Aggregate<byte, BigInteger>(0, (current, t) => current * 256 + t);
    string result = intData.ToString();
    return result;
}
Run Code Online (Sandbox Code Playgroud)

current和t之前没有在任何地方定义如此诚实,我不知道除了调用.Aggregate函数之外还使用了什么"byte [] data"的作用.

另外data.Aggregate =累积函数......我的直觉是"字节"扮演当前的角色,"BigInteger"扮演t的角色.

public static TAccumulate Aggregate<TSource, TAccumulate>(this IEnumerable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> func);
Run Code Online (Sandbox Code Playgroud)

Mur*_*nik 6

lambda表达式定义了一个匿名Func聚合data字节数组,其中处理了数组的每个元素.current表示到目前为止的结果,并且t是正在处理的元素.在此示例中,函数迭代数组,并为每个元素将当前结果乘以256并添加正在处理的元素.