函数 SetArcCostEvaluatorOfAllVehicles() 出错;

问题描述 投票:0回答:1

当我尝试通过以下函数设置成本时:

routing.SetArcCostEvaluatorOfAllVehicles((i, j) =>
        {
            return (int)distanciaMatriz[manager.IndexToNode(i), manager.IndexToNode(j)];
        });

它返回以下错误:

Error CS1660 Unable to convert lambda expression to type "int" because it is not a delegate type.

如何解决这个问题?我已经尝试过直接将 return 转换为 int,但什么也没发生。

c# .net routes error-handling constraints
1个回答
0
投票

您可以尝试将它们分配给 int 变量以确保它们匹配吗

int nodeI = manager.IndexToNode(i);
int nodeJ = manager.IndexToNode(j);
return (int)distanciaMatriz[nodeI, nodeJ];
© www.soinside.com 2019 - 2024. All rights reserved.