Skip to content

CS0837 applies to method groups as well? #14146

Closed

Description

@codeganesh

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.

Activity

  1. MSDN-WhiteKnight commented on Sep 4, 2019

    @MSDN-WhiteKnight
    Contributor

    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.

  2. codeganesh commented on Sep 4, 2019

    @codeganesh
    Author

    Thank you for the clarification!

  3. added this to the September 2019 milestone on Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions