Name
AttributeUsage Attribute
Class
System.AttributeUsageAttribute
Applies to
Class
Description
Defines the program elements to which a custom attribute can be applied. Its use is required when defining a custom attribute.
Constructor
New(validOn)-
validOn(System.AttributeTargets) Indicates the program elements to which a custom attribute can be applied. Possible values are
All,Assembly,Class,Constructor,Delegate,Enum,Event,Field,Interface,Struct,Method,Module,Parameter,Property, andReturnValue.
Properties
- AllowMultiple (Boolean)
Indicates whether the attribute can be used more than once on a single program element. Its default value is
False.- Inherited (Boolean)
Indicates whether attribute is automatically inherited by derived classes and overridden members. Its default value is
True.- ValidOn (
AttributeTargetsenumeration) Read-only. Indicates the program elements to which the attribute can be applied. Its value is set by the required
validonparameter of the class constructor.
Example
See Section 8.2 in Chapter 8 for more details and an example.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access