MethodGroup causes ambiguity over the same lambda expression #1245
Replies: 3 comments
-
FYI have raised an issue @jrote1 |
Beta Was this translation helpful? Give feedback.
-
This appears unrelated to public interface IBuilder
{
void Property( Func<string> source );
void Property( Func<int> source );
}
class Program
{
static void Main( string[] args )
{
IBuilder builder = null;
builder.Property( Source ); // ambiguous call
}
private static int Source()
{
return 0;
}
} Method groups are resolved using the arity and types of the parameters, not the return type. So presumably since you are using |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Given the following interface:
The following does not compile:
However, if you pass a lambda expression which just invokes
Source
then it compiles fine:builder.Property( () => Source() );
Why is the first call (using method grouping) failing? A bug..?
Beta Was this translation helpful? Give feedback.
All reactions