Cannot convert type 'System.Func<int,bool>' to 'System.Func<object,bool>'
尝试将 f2 转换为 f1:
Func<object, bool> f1 = x => true;
Func<int, bool> f2 = x => true;
f1 = (Func<object, bool>)f2;
尝试了地图功能来解决,但是这次我得到了
Argument 1: cannot convert from 'C' to 'A'
例外。关于 transform(a) 函数
Func<int, bool> f3 = Map(f2, x => x);
Func<C, B> Map<A, B, C>(Func<A, B> input, Func<A, C> transform)
{
return x => input(transform(x));
// return x => input(transform((A)x)); not working
}
有解决办法吗?