C# .NET - Attributes in C#2 0 - Asked By jason smith on 22-Aug-06 11:47 AM

am trying to learn C# (2.0). 

I think I am okay with the concept of Generics now and I have done some decent number of sample code. 

I came across Attributes and I am trying to find out how often they are useful in the real world and under what circumstances they are used. If they are not of great help I would like to skip (for now) and start learning about Delegates. 

any suggestions will be very helpful 
thanks 
nath

Attributes are used throughout the NET Framework - Asked By Peter Bromberg on 22-Aug-06 11:57 AM

It's a class, and it is used to annotate or add additional infrastructure or transport information to an assembly, a class, method, or field.

for example, if you look in your AssemblyInfo.cs file, you will see attributes for the assembly.

If you look at a WebService method you will see the attribute "WebMethod". etc.

Now you can move on to Delegates.

thanks Peter - Asked By jason smith on 22-Aug-06 12:17 PM

regards
nath

There are all sorts of uses for custom attributes - Asked By Robbe Morris on 22-Aug-06 01:19 PM

Here is one that I rely on alot.  It use them to auto populate custom classes from DataTables.

this focuses on attributes themselves.

http://www.eggheadcafe.com/articles/map_storedprocedure_to_class_property.asp

This is an updated version utilizing generics and attributes:

http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp
thanks much - Asked By jason smith on 22-Aug-06 03:30 PM
regards
nath