Mono中System.Linq.Enumerable.Max之间的模糊调用

时间:2014-06-18 15:35:03

标签: c# linq mono

当使用lambda表达式从以下代码中查找最大Key值时,在使用gmcs在Unix系统上进行编译时会出现以下编译错误:

List<KeyValuePair<int, RunnerBase>> lsFinishOrder = new List<KeyValuePair<int, RunnerBase>>();

...fill out List...

iMaxPlace = lsFinishOrder.Max(p => p.Key);

代码在Windows机器上编译正常,并且在执行时按预期执行,只有在我尝试在Linux上编译时才会出现问题。

  

错误CS0121:以下方法之间的呼叫不明确或   特性:   `System.Linq.Enumerable.Max&LT; System.Collections.Generic.KeyValuePair&LT; INT,Pathfinder.RunnerBase&GT;&GT;(System.Collections.Generic.IEnumerable&LT; System.Collections.Generic.KeyValuePair&LT; INT,Pathfinder.RunnerBase&GT;&GT; ,   System.Func&lt; System.Collections.Generic.KeyValuePair&lt; int,Pathfinder.RunnerBase&gt;, long &gt;)'

     

和   `System.Linq.Enumerable.Max&LT; System.Collections.Generic.KeyValuePair&LT; INT,Pathfinder.RunnerBase&GT;&GT;(System.Collections.Generic.IEnumerable&LT; System.Collections.Generic.KeyValuePair&LT; INT,Pathfinder.RunnerBase&GT;&GT; ,   System.Func&lt; System.Collections.Generic.KeyValuePair&lt; int,Pathfinder.RunnerBase&gt;, int &gt;)'

     

/usr/lib/mono/gac/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll   (与先前错误相关的符号的位置)

任何想法都会受到欢迎,因为我尝试了很多不同的方法,我想知道我是不是在寻找错误的地方。我的Windows构建目标是.Net 3.5。

1 个答案:

答案 0 :(得分:2)

这看起来像是Mono编译器中的一个错误。

试试这个来帮助它:

iMaxPlace = lsFinishOrder.Max((Func<KeyValuePair<int, RunnerBase>, int>)(p => p.Key));
相关问题