I have conducted the following inference tests:
static class InferenceTest {
static void TakeInt(int a) { }
static int GiveInt() { return 0; }
static
In general, a method name will not uniquely identify a unique type Action
to which the method group could be assigned. For example, even if there's only one overload of Fred
and it takes a single Cat
argument, that overload could be assigned not just to an Action
, but also to some other types like Action
, Action
, or Action
. While there are some cases where one type substitution would be in every way superior to any alternative, that is not always the case. It's cleaner to define the language to require that the type of delegate be specified, than to have the compiler try to "guess", especially since having the compiler guess would mean that many things which shouldn't be breaking changes, would be (e.g. adding a method overload may render ambiguous a type inference which used to work).