带for循环的c#lambda表达式

带for循环的c#lambda表达式,c#,lambda,delegates,ilnumerics,C#,Lambda,Delegates,Ilnumerics,我正在使用这段代码在每个点上构建3d曲面图,但我有一个问题,我需要参数化我的函数,使t变量从0循环到t值,但我不知道如何在代理内部实现它 为了更清晰,编辑了第一个块: /*this is code for building 3d surface plot, parameter delegate is counting Z value in each (x, y) point. x, y are axis variables. t is constant here*/ new ILPlot

我正在使用这段代码在每个点上构建3d曲面图,但我有一个问题,我需要参数化我的函数,使t变量从0循环到t值,但我不知道如何在代理内部实现它

为了更清晰,编辑了第一个块:

/*this is code for building 3d surface plot, parameter delegate is counting Z
  value in each (x, y) point.
  x, y are axis variables. t is constant here*/
new ILPlotCube()
{ 
    new ILSurface((x, y) => (float) (1/(x+y+t))
}
生成的伪代码类似于:

float functionValue = 0;
for (double t = 0; t < T; t + deltaT)
{
     /*t is loop parameter here*/
     functionValue += (float) (1/(x+y+t));   
}
return functionValue;
float functionValue=0;
对于(双t=0;t
如果不需要表达式树,那么它应该是:

Func<float, float, float> func = (x, y) =>
{
    float functionValue = 0;
    for (double t = 0; t < T; t += deltaT)
    {
        /*t is loop parameter here*/
        functionValue += (float)(1 / (x + y + t));
    }
    return functionValue;
};

这是一个
语句lambda
,因为它在
=>
后面使用
{…}
代码。请参阅
语句lambdas

我认为您应该参加一场模糊C#code竞赛。。。我读第一个代码块已经三分钟了,我仍然不确定谁是who的参数
new ILSurface(func);