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.3. Naming attribute classes and attribute specifications

By convention, attribute class names are post-pended with 'Attribute' (we have named our attribute classes AuthorAttribute, StatusOfClassAttribute, and BuggyAttribute). This is not compulsory, but it is conventional and highly recommended.

You might have realized that when using the three attributes as attribute specifications in MyClass.cs, I used the shortcut Author instead of AuthorAttribute, and Buggy instead of BuggyAttribute. The C# compiler automatically searches for the AuthorAttribute class when it encounters 'Author' in an attribute specification. [3]

[3] It is possible to write two separate attribute classes – one by the name of AuthorAttribute, and the other called Author ...

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