O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required