LinqKit提供了一个对于IEnumerable
的扩展方法ForEach
,该方法会与System.Collections.Generic.IEnumerable
冲突。
Error 4 The call is ambiguous between the following methods or properties:
'LinqKit.Extensions.ForEach<Domain>(System.Collections.Generic.IEnumerable<Domain>, System.Action<Domain>)'
and
'System.Linq.EnumerableExtensionMethods.ForEach<Domain>(System.Collections.Generic.IEnumerable<Domain>, System.Action<Domain>)'
我怎样才能消除这个错误?
ForEach
扩展方法可能不是最佳选择... 值得一读:http://blogs.msdn.com/b/ericlippert/archive/2009/05/18/foreach-vs-foreach.aspx - Reed CopseySystem.Linq.EnumerableExtensionMethods
库是来自哪里的? - StriplingWarriorselect
代替map
,使用aggregate
代替foldl
,根本没有foldr
...)。相比之下,Scala有一个foreach
方法,即使它有一个for
语句来迭代集合...实际上,for
循环会扩展为调用foreach
(以及其他一些东西)。Scala允许命令式编码风格,但在各种方式上鼓励程序员朝着函数式风格发展。 - Jim Balter