This one\'s got me flummoxed, so I thought I\'d ask here in the hope that a C# guru can explain it to me.
Why does this code generate an error?
class
Your code requires "magic" to take place twice, once to convert from the named method group to a delegate, and once to perform overload resolution.
Despite the fact that you have only one method named X, the compiler rules are built for the case when there are multiple.
In addition, since delegates don't have to match the method signature exactly, the complexity is further increased. On top of that, any given method can be converted to an unlimited number of different delegate types with identical signatures.
Your particular case looks straightforward enough, but the general case is very very hard, so the language doesn't allow it.
If you do part of the work by hand, you'll solve the problem. e.g.
Func d = X;
Foo(d);
should compile just fine.