I was thinking about the difference between Expression<Func<>>
and Func<>
, and wondered if you could convert a static method to an expression tree as follows:
class Program
{
static void Main(string[] args)
{
Func<int, int> t = x => hrm(x);
Func<int, int> t2 = new Func<int, int>(hrm);
// Works as expected:
Expression<Func<int, int>> et = x => hrm(x);
// Brokenness:
Expression<Func<int, int>> et2 = new Func<int, int>(hrm);
}
static int hrm(int x)
{
return x + 9;
}
}
What's so special about the second "Func<>" that it can't be converted to an Expression, when the first one can?