views:

70

answers:

1

Possible Duplicate:
When should I use attribute in C#?

Hi, I am trying to understand how Attributes in .net works.

As we all know Attributes are of two types metadata and context attributes.

Metadata attributes: it allows some data to be attached to a class or method. This data becomes part of the metadata for the class, and can be accessed via reflection.

Firstly, why do we need custom attributes please give examples and How is that information attached with that class and how will it be interpreted.

Custom attributes: Please explain this and explain the flow how is that custom class which is derived System.Attribute is executed and how will that information be useful to the current class or method which uses that attribute. (best example is Validation Block is applied as attributes to the property or methods and it will be automatically validated. how is this possible).

I have the basic understanding of attributes and how it works and looking at the process how that works.

Thanks in advance.