为什么编译器不能处理这些x3
和x4
赋值?
void X()
{
(Func<int, int>, int) x1 = (GetX, 1); // OK
object x2 = x1; // OK
object x3 = (GetX, 1); // Error CS8135 Tuple with 2 elements cannot be converted to type 'object'.
object x4 = (GetX, 1) as (Func<int, int>, int); // Error CS8307 The first operand of an 'as' operator may not be a tuple literal without a natural type.
object x5 = ((Func<int, int>, int))(GetX, 1); // OK
object x6 = ((Func<int, int>)GetX, 1); // OK
}
int GetX(int x)
{
return x;
}