Export (0) Print
Expand All
26 out of 41 rated this helpful - Rate this topic

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).

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.