Skip to content

nameof expression with a method parameter inside an attribute works with C# versions before 11 #32599

@cremor

Description

@cremor

The page says

Beginning with C# 11, you can use a nameof expression with a method parameter inside an attribute on a method or its parameter.

This is not 100% correct. A nameof expression with a method parameter inside an attribute even works with C# versions before 11 as long as you use a compiler that knows C# 11.

Reference: dotnet/roslyn#65379 (comment)


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions