Confusion with method groups #7193
Replies: 2 comments 8 replies
-
This also seems to be specific to some things (tuples, conditional expressions) and not other things (e.g. static bool Run(string arg) => true;
void F()
{
var tuple1 = ("Run", PassThrough(Run)); // Works
}
static T PassThrough<T>(T v) => v; |
Beta Was this translation helpful? Give feedback.
-
The reason why any of those usages of
By doing a git blame, I found the PR which documented this decision, which very helpfully had a link to the meeting notes which decided this approach, but what was discussed was only immediately-invoked function members. It's not clear if the concluding list of limitations was only derived from blocking IIFEs or if it was a continuation from some other meeting where these limitations were discussed. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Recently, I typed a line of C# code that did not compile, though I wish compiler to understand it.
Consider a following snapshot:
It's clear that the C# compiler stumbles dealing with method groups.
I would like for the following lines to be valid:
It would be good for C# compiler to be able to coerce a method group with single member as a lambda, thus to avoid unnecessary code.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions