Name

AttributeUsageAttribute

Synopsis

This attribute is used when developing a custom attribute class. It allows you to specify how your custom attribute must be used. The ValidOn property uses a bitwise combination of values from AttributeTargets to specify the code elements that can use your custom attribute. It’s read-only and must be initialized using the constructor, as in (AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)).

The AllowMultiple property specifies whether the attribute can be used more than once for the same element. The Inherited attribute specifies whether your custom attribute will be applied to derived classes and overridden members. These are indicated using the usual named parameter syntax supported by attributes, as in (AttributeUsage(Inherited = true, AllowMultiple = true))

Public NotInheritable Class AttributeUsageAttribute : Inherits Attribute
' Public Constructors
   Public Sub New( ByVal validOn As AttributeTargets) 
' Public Instance Properties
   Public Property AllowMultiple As Boolean  
   Public Property Inherited As Boolean  
   Public ReadOnly Property ValidOn As AttributeTargets  
End Class

Hierarchy

ObjectAttribute AttributeUsageAttribute

Valid On

Class

Get VB.NET Core Classes in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.