方法&#39; Enumerable.Zip的类型参数<tfirst,tsecond,=“”tresult =“”>(IEnumerable <tfirst>,IEnumerable <tsecond>,Func <tfirst,

时间:2017-02-13 05:11:12

标签: c# .net linq

=“”

获取错误

  

方法的类型参数&#39; Enumerable.Zip(IEnumerable,IEnumerable,Func)&#39;无法从使用中推断出来。尝试指定   类型参数显式

on

IEnumerable<Coordinate> perimeter = GetCoordinates(k, m, n);
IEnumerable<Coordinate> source = perimeter.Skip(r).Concat(perimeter.Take(r));
perimeter.Zip(source, (p, s) =>
{
    matrix[p.X, p.Y] = matrix[s.X, s.Y];
});

无法弄清楚我在做什么,这与我在这里阅读的文档不一致:https://msdn.microsoft.com/en-us/library/dd267698(v=vs.110).aspx

1 个答案:

答案 0 :(得分:2)

Zip必须返回结果。如果您不需要Zip来返回任何内容,那么您可以将return true;添加到匿名函数中:

IEnumerable<Coordinate> perimeter = GetCoordinates(k, m, n);
IEnumerable<Coordinate> source = perimeter.Skip(r).Concat(perimeter.Take(r));
perimeter.Zip(source, (p, s) =>
{
    matrix[p.X, p.Y] = matrix[s.X, s.Y];
    return true;
});
相关问题