Attributes
The .NET Framework makes extensive use of attributes, descriptive pieces of read-only information that a programmer can place in an object's metadata. Attributes can be read by any interested piece of code that has the required level of permission. Many attributes are provided and used by the system. Others are defined by programmers and used for their own purposes. All attributes derive from the abstract base class System.Attribute. The attributes in Table 2 were felt to be common enough to occupy the System namespace. Many other subordinate namespaces also define more specialized attributes.
Table 2.
Attributes |
Meaning |
---|---|
AttributeUsageAttribute |
Used in the definition of other attribute classes, specifying the target types to which the other attribute class can be applied (assembly, class, method, some combination, etc.). Uses AttributeTargets enumeration. |
CLSCompliantAttribute |
Indicates whether a program element is compliant with the Common Language Specification (CLS). |
FlagsAttribute |
Indicates that an enumeration can be treated as a bit field; that is, a set of flags. |
ObsoleteAttribute |
Marks the program elements that are no longer in use. |