Intrinsic Attributes
Attributes come in two flavors:
intrinsic
and custom
.
Intrinsic attributes are supplied as part of the
Common Language Runtime (CLR), and they are integrated into .NET.
Custom attributes are attributes you create for
your own purposes.
Most programmers will use only intrinsic attributes, though custom attributes can be a powerful tool when combined with reflection, described later in this chapter.
Attribute Targets
If
you
search through the CLR, you’ll find a great many attributes.
Some attributes are applied to an assembly, others to a class or
interface, and some, such as [WebMethod], to class
members. These are called the attribute targets.
Possible attribute targets are detailed in Table 18-1.
Table 18-1. Possible attribute targets
|
Member Name |
Usage |
|---|---|
|
|
Applied to any of the following elements: assembly, class, class member, delegate, enum, event, field, interface, method, module, parameter, property, return value, or struct |
|
|
Applied to the assembly itself |
|
|
Applied to instances of the class |
|
|
Applied to classes, structs, enums, constructors, methods, properties, fields, events, delegates, and interfaces |
|
|
Applied to a given constructor |
|
|
Applied to the delegated method |
|
|
Applied to an enumeration |
|
|
Applied to an event |
|
|
Applied to a field |
|
|
Applied to an interface |
|
|
Applied to a method |
|
|
Applied to a single module |
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