[Previous] [Contents] [Next]

The AttributeUsage Attribute

In addition to custom attributes that you use to annotate regular C# types, you can use the AttributeUsage attribute to define how you want these attributes to be used. The AttributeUsage attribute has the following documented calling conventions: -

[AttributeUsage(
validon,
AllowMultiple = allowmultiple,
Inherited = inherited
)]

As you can see, it's easy to discern which are positional parameters and which are named parameters. I would strongly recommend that you document your attributes in this fashion so that the user of your attribute doesn't need to look through your attribute class's source code to find the public read/write fields and properties that can be used as named attributes.

[Previous] [Contents] [Next]