You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Visual Studio 2019, when I used a method group on the left hand side of "is",I got a compiler error "The first operand of an 'is' or 'as' operator may not be a lambda expression, anonymous method, or method group". Is this new in this current version of C#?
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
ID: 946a6568-a1aa-4844-7959-263c79935bb3
Version Independent ID: 5d65bbcc-bedc-b39b-feba-a184ce97926d
This is certainly not new. In fact, in the addition of "method group" in this message was already there in the first roslyn sources instance on Github (Jan 2015). VS 2017 outputs the same as well. But VS2012 with c# 5.0 compiles if (Main is Delegate ), just outputs warning that Main would never be of that type. (By the way, why? Method group should have implicit cast to delegate. And what is the actual type of method group?) So it was introduced somewhere in c# 5.x - 6.0. This article and example should be updated.
Activity
MSDN-WhiteKnight commentedon Sep 4, 2019
This is certainly not new. In fact, in the addition of "method group" in this message was already there in the first roslyn sources instance on Github (Jan 2015). VS 2017 outputs the same as well. But VS2012 with c# 5.0 compiles
if (Main is Delegate ), just outputs warning that Main would never be of that type. (By the way, why? Method group should have implicit cast to delegate. And what is the actual type of method group?) So it was introduced somewhere in c# 5.x - 6.0. This article and example should be updated.codeganesh commentedon Sep 4, 2019
Thank you for the clarification!