c# - System.Linq.Enumerable.Max 的 Mono 之间的模糊调用

标签 c# linq mono

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

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

...fill out List...

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

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

error CS0121: The call is ambiguous between the following methods or properties: `System.Linq.Enumerable.Max<System.Collections.Generic.KeyValuePair<int,Pathfinder.RunnerBase>>(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<int,Pathfinder.RunnerBase>>, System.Func<System.Collections.Generic.KeyValuePair<int,Pathfinder.RunnerBase>, long >)'

and `System.Linq.Enumerable.Max<System.Collections.Generic.KeyValuePair<int,Pathfinder.RunnerBase>>(System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<int,Pathfinder.RunnerBase>>, System.Func<System.Collections.Generic.KeyValuePair<int,Pathfinder.RunnerBase>, int >)'

/usr/lib/mono/gac/System.Core/3.5.0.0__b77a5c561934e089/System.Core.dll (Location of the symbol related to previous error)

任何想法都将受到欢迎,因为我已经尝试了很多不同的方法,我想知道我是否没有找错地方。我的 Windows 构建目标是 .Net 3.5。

最佳答案

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

试试这个来帮助它:

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

关于c# - System.Linq.Enumerable.Max 的 Mono 之间的模糊调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24289652/

相关文章:

.net - ASP.NET Web API(测试版)是否可以与最新的 Mono(稳定版)一起运行?

c# - 如果我在 c# 中注册一个事件,而它正在调度,我是否保证在该调度期间不会再次被调用?

c# - 在 ASP.NET MVC 中,当 Model.isvalid 为 false 时如何将验证消息重定向并显示回局部 View

c# - 是否可以编写使用 xamarin 表单(UI)和 Unity(3D 部分)开发的非游戏跨平台 3D 可视化移动应用程序?

c# - 使用 LINQ 从 List 或 foreach 循环中获取行是否更快

c# - 在 int List 中插入一个值然后对列表进行排序的最快方法

C# 将时间列表拆分为时间范围

CodeRunner 2 中的 C# 汇编

c# - MVC4 种子数据库外键 ID

c# - ORM/持久层建议