Because the compiler cannot figure out what type of RHS has
var add = (x, y) => x + y;
Any type that supports the + operator is a candidate, and since the types x and y are not a restriction of the same type. There were excluded many possible + operators that could be used, and therefore the set of possible types for x and y is quite large, but to determine the type of addition, the compiler should be able to reduce the set to only one type for x and one for y (not quite true , it is possible that both the base class and the derived class will match), and yet, even if the compiler can determine the type for x and y or that you specify types to say int , you will still be left with the fact that both Expression<Func<int,int,int>> and Func<int,int,int> are possible types Pami to add
There are several options for reducing the set of possible types. The compiler may try to see how add will be used later, but not (and perhaps could not determine the types, even if this were done)
Rune FS Aug 01 '11 at 11:23 2011-08-01 11:23
source share