Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 6
    "I would like to be able to write ..." -- as of C# 10 (.NET 6), you can. sharplab.io/… Commented Oct 17, 2024 at 7:59
  • 5
    Before C#10, you can write "This property is obsolete. Use " + nameof(NewProperty) + " instead." Commented Oct 17, 2024 at 8:01
  • Thanks! I forgot I was on an old project. I got An attribute argument must be a constant expression, 'typeof()' expression or array creation expression of an attribute parameter type when trying to do so, I did not think to check in later language version. Would you like to write it as an answer so I can accept it as resolved? Commented Oct 17, 2024 at 8:43
  • 1
    As an aside, classes that define attributes by convention always end with "Attribute", but when you use them as attributes, you drop that part of the name: [Obsolete] not [ObsoleteAttribute] Commented Oct 17, 2024 at 10:42