这个让我很困惑,所以我想我会在这里问,希望 C# 大师可以向我解释。
为什么这段代码会产生错误?
Func<IEnumerable<Item>, IEnumerable<Item>, IEqualityComparer<Item>, IEnumerable<Item>> func = strict ?
(first, second, comparer) => first.Intersect(second, comparer) :
(first, second, comparer) => first.Union(second, comparer);
而这个没有:
Func<IEnumerable<Item>, IEnumerable<Item>, IEqualityComparer<Item>, IEnumerable<Item>> func1;
if (strict)
func1 = (first, second, comparer) => first.Intersect(second, comparer);
else
func1 = (first, second, comparer) => first.Union(second, comparer);