Name
AttributeTargets
Synopsis
This enumeration is used to set the AttributeUsageAttribute.ValidOn
property when creating a custom attribute. It allows you to
specify the code elements for which a custom attribute can be
used. You can use a bitwise combination of these values to
specify multiple elements.
Using this attribute is the only means by which a custom attribute can
declare a restriction of its usage against various metadata types. For
example, when using the System.Reflection.AssemblyKeyFileAttribute
attribute, which simply
tells the compiler which public/private keyfile to use to sign the
assembly, it makes no sense to apply to any other metadata type besides the
assembly. Therefore, the AssemblyKeyFileAttribute
attribute
has an AttributeUsageAttribute
(see the AttributeUsageAttribute
entry) declared on it
with the value Assembly
. As a result,
any attempt to use the AssemblyKeyFileAttribute
attribute on
anything other than an assembly results in a compilation error.
Public Enum AttributeTargets Assembly = &H000000001 Module = &H000000002 Class = &H000000004 Struct = &H000000008 Enum = &H000000010 Constructor = &H000000020 Method = &H000000040 Property = &H000000080 Field = &H000000100 Event = &H000000200 Interface = &H000000400 Parameter = &H000000800 Delegate = &H000001000 ReturnValue = &H000002000 All = &H000003FFF End Enum
Hierarchy
Object→ValueType→ Enum(IComparable
, IFormattable
, IConvertible)→ AttributeTargets
Returned By
AttributeUsageAttribute.ValidOn
Passed ...
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.