28.2. Another custom attribute example
Let's complicate things a bit more by writing another custom attribute – this time for a class only. Let's modify AttributeClass.cs to include two more attribute classes called StatusOfClassAttribute and BuggyAttribute:
StatusOfClassAttribute shall be a class-only attribute (you can only use it to tag a class, not a method nor any other class entity). This attribute will be used to denote if the class is completed, or still under development.
BuggyAttribute shall be a method-only attribute used by a team leader to tag poorly written methods from sleep-deprived developers. BuggyAttribute doesn't contain any fields within the attribute class.
Here's the new AttributeClass.cs:
1: // AttributeClass.cs 2: using ...
Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.