17. Attributes
The document is archived and information here might be outdated

17. Attributes

Visual Studio .NET 2003

Much of the C# language enables the programmer to specify declarative information about the entities defined in the program. For example, the accessibility of a method in a class is specified by decorating it with the method-modifiers public, protected, internal, and private.

C# enables programmers to invent new kinds of declarative information, called attributes. Programmers can then attach attributes to various program entities, and retrieve attribute information in a run-time environment. For instance, a framework might define a HelpAttribute attribute that can be placed on certain program elements (such as classes and methods) to provide a mapping from those program elements to their documentation.

Attributes are defined through the declaration of attribute classes (Section 17.1), which may have positional and named parameters (Section 17.1.2). Attributes are attached to entities in a C# program using attribute specifications (Section 17.2), and can be retrieved at run-time as attribute instances (Section 17.3).

© 2016 Microsoft