rbulph Posted December 20, 2005 Posted December 20, 2005 If I define a custom attribute with "Attribute" at the end of its name, I can use that attribute without putting "Attribute" at the end of its name, as follows: <AttributeUsage(AttributeTargets.All)> Public Class ContreAttribute Inherits Attribute End Class <Contre()> Public Class ABCAttribute End Class I was rather surprised to see that the above doesn't generate any errors. It's not a problem, but I'm just wondering if it's part of a wider rule that I should know about or whether it just applies for Attributes. Anyone know? Quote
Leaders snarfblam Posted December 20, 2005 Leaders Posted December 20, 2005 This is correct behavior. It is just abbreviated syntax to make code look cleaner. Rather than having "attribute" inside every attribute tag, your code can read and look more concise. Suffixing attribute classes with "Attribute" is a special naming convention honored by C# and VB. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.