Monday, May 21, 2007

Attributes

When do you need to use attributes?
Attributes are used to:
· define sections of code that are only included in Debug builds
· define information about an assembly, such as the copyright information
· mark sections of code as obsolete, so that overt time you can revise your assemblies

What is an attribute?
An attribute is extra information that can be applied to chunks of code within an assembly – such as a class, method, or property. This information is accessible to any other class that uses the assembly.

Define Attributes?
Attributes are a mechanism for adding metadata, such as compiler instructions and other data about your data, methods, and classes, to the program itself. Attributes are inserted into the metadata and are visible through ILDasm and other metadata-reading tools.

Use of Attributes
The initial idea of an attribute was that it provided extra information concerning some item in the program that could be used by the compiler.
The user-defined attributes will be placed with the Meta data for the corresponding data types or methods.

No comments: